hangup() cleanup; SIGXCPU handling

This commit is contained in:
nethack.rankin
2007-01-09 05:29:17 +00:00
parent 1c20fe6223
commit f2d8a53718
7 changed files with 60 additions and 49 deletions

View File

@@ -178,7 +178,7 @@ done_hangup(sig) /* signal() handler */
int sig;
{
program_state.done_hup++;
(void)signal(SIGHUP, SIG_IGN);
sethanguphandler((void FDECL((*),(int)))SIG_IGN);
done_intr(sig);
return;
}
@@ -662,7 +662,7 @@ die:
(void) signal(SIGINT, (SIG_RET_TYPE) done_intr);
# if defined(UNIX) || defined(VMS) || defined (__EMX__)
(void) signal(SIGQUIT, (SIG_RET_TYPE) done_intr);
(void) signal(SIGHUP, (SIG_RET_TYPE) done_hangup);
sethanguphandler(done_hangup);
# endif
#endif /* NO_SIGNAL */
@@ -1034,6 +1034,11 @@ int status;
dlb_cleanup();
}
#ifdef VMS
/* don't call exit() if already executing within an exit handler;
that would cancel any other pending user-mode handlers */
if (program_state.exiting) return;
#endif
nethack_exit(status);
}

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)files.c 3.5 2006/12/09 */
/* SCCS Id: @(#)files.c 3.5 2007/01/08 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -564,7 +564,7 @@ clearlocks()
register int x;
# if defined(UNIX) || defined(VMS)
(void) signal(SIGHUP, SIG_IGN);
sethanguphandler((void FDECL((*),(int)))SIG_IGN);
# endif
/* can't access maxledgerno() before dungeons are created -dlc */
for (x = (n_dgns ? maxledgerno() : 0); x >= 0; x--)

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)save.c 3.5 2006/04/14 */
/* SCCS Id: @(#)save.c 3.5 2007/01/08 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -140,9 +140,7 @@ int sig_unused;
# ifdef NOSAVEONHANGUP
(void) signal(SIGINT, SIG_IGN);
clearlocks();
# ifndef VMS
terminate(EXIT_FAILURE);
# endif
# else /* SAVEONHANGUP */
if (!program_state.done_hup++) {
# ifndef SAFERHANGUP
@@ -152,18 +150,12 @@ int sig_unused;
* against losing objects in the process of being thrown. */
if (program_state.something_worth_saving)
(void) dosave0();
# ifdef VMS
/* don't call exit when already within an exit handler;
that would cancel any other pending user-mode handlers */
if (!program_state.exiting)
# endif
{
clearlocks();
terminate(EXIT_FAILURE);
}
clearlocks();
terminate(EXIT_FAILURE);
# endif /* !SAFERHANGUP */
}
# endif
# endif /* !NOSAVEONHANGUP */
}
#endif
@@ -182,7 +174,7 @@ dosave0()
fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */
#if defined(UNIX) || defined(VMS)
(void) signal(SIGHUP, SIG_IGN);
sethanguphandler((void FDECL((*),(int)))SIG_IGN);
#endif
#ifndef NO_SIGNAL
(void) signal(SIGINT, SIG_IGN);