hangup() cleanup; SIGXCPU handling
This commit is contained in:
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
/* SCCS Id: @(#)os2conf.h 3.5 1996/10/29 */
|
/* SCCS Id: @(#)os2conf.h 3.5 2007/01/08 */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* Copyright (c) Timo Hakulinen, 1990, 1991, 1992, 1993, 1996. */
|
/* Copyright (c) Timo Hakulinen, 1990, 1991, 1992, 1993, 1996. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -95,6 +95,7 @@
|
|||||||
|
|
||||||
#ifdef __EMX__
|
#ifdef __EMX__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#define sethanguphandler(foo) (void)signal(SIGHUP, (SIG_RET_TYPE)foo)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef REDO
|
#ifndef REDO
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ done_hangup(sig) /* signal() handler */
|
|||||||
int sig;
|
int sig;
|
||||||
{
|
{
|
||||||
program_state.done_hup++;
|
program_state.done_hup++;
|
||||||
(void)signal(SIGHUP, SIG_IGN);
|
sethanguphandler((void FDECL((*),(int)))SIG_IGN);
|
||||||
done_intr(sig);
|
done_intr(sig);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -662,7 +662,7 @@ die:
|
|||||||
(void) signal(SIGINT, (SIG_RET_TYPE) done_intr);
|
(void) signal(SIGINT, (SIG_RET_TYPE) done_intr);
|
||||||
# if defined(UNIX) || defined(VMS) || defined (__EMX__)
|
# if defined(UNIX) || defined(VMS) || defined (__EMX__)
|
||||||
(void) signal(SIGQUIT, (SIG_RET_TYPE) done_intr);
|
(void) signal(SIGQUIT, (SIG_RET_TYPE) done_intr);
|
||||||
(void) signal(SIGHUP, (SIG_RET_TYPE) done_hangup);
|
sethanguphandler(done_hangup);
|
||||||
# endif
|
# endif
|
||||||
#endif /* NO_SIGNAL */
|
#endif /* NO_SIGNAL */
|
||||||
|
|
||||||
@@ -1034,6 +1034,11 @@ int status;
|
|||||||
dlb_cleanup();
|
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);
|
nethack_exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -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. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -564,7 +564,7 @@ clearlocks()
|
|||||||
register int x;
|
register int x;
|
||||||
|
|
||||||
# if defined(UNIX) || defined(VMS)
|
# if defined(UNIX) || defined(VMS)
|
||||||
(void) signal(SIGHUP, SIG_IGN);
|
sethanguphandler((void FDECL((*),(int)))SIG_IGN);
|
||||||
# endif
|
# endif
|
||||||
/* can't access maxledgerno() before dungeons are created -dlc */
|
/* can't access maxledgerno() before dungeons are created -dlc */
|
||||||
for (x = (n_dgns ? maxledgerno() : 0); x >= 0; x--)
|
for (x = (n_dgns ? maxledgerno() : 0); x >= 0; x--)
|
||||||
|
|||||||
+6
-14
@@ -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. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -140,9 +140,7 @@ int sig_unused;
|
|||||||
# ifdef NOSAVEONHANGUP
|
# ifdef NOSAVEONHANGUP
|
||||||
(void) signal(SIGINT, SIG_IGN);
|
(void) signal(SIGINT, SIG_IGN);
|
||||||
clearlocks();
|
clearlocks();
|
||||||
# ifndef VMS
|
|
||||||
terminate(EXIT_FAILURE);
|
terminate(EXIT_FAILURE);
|
||||||
# endif
|
|
||||||
# else /* SAVEONHANGUP */
|
# else /* SAVEONHANGUP */
|
||||||
if (!program_state.done_hup++) {
|
if (!program_state.done_hup++) {
|
||||||
# ifndef SAFERHANGUP
|
# ifndef SAFERHANGUP
|
||||||
@@ -152,18 +150,12 @@ int sig_unused;
|
|||||||
* against losing objects in the process of being thrown. */
|
* against losing objects in the process of being thrown. */
|
||||||
if (program_state.something_worth_saving)
|
if (program_state.something_worth_saving)
|
||||||
(void) dosave0();
|
(void) dosave0();
|
||||||
# ifdef VMS
|
|
||||||
/* don't call exit when already within an exit handler;
|
clearlocks();
|
||||||
that would cancel any other pending user-mode handlers */
|
terminate(EXIT_FAILURE);
|
||||||
if (!program_state.exiting)
|
|
||||||
# endif
|
|
||||||
{
|
|
||||||
clearlocks();
|
|
||||||
terminate(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
# endif /* !SAFERHANGUP */
|
# endif /* !SAFERHANGUP */
|
||||||
}
|
}
|
||||||
# endif
|
# endif /* !NOSAVEONHANGUP */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -182,7 +174,7 @@ dosave0()
|
|||||||
fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */
|
fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */
|
||||||
|
|
||||||
#if defined(UNIX) || defined(VMS)
|
#if defined(UNIX) || defined(VMS)
|
||||||
(void) signal(SIGHUP, SIG_IGN);
|
sethanguphandler((void FDECL((*),(int)))SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_SIGNAL
|
#ifndef NO_SIGNAL
|
||||||
(void) signal(SIGINT, SIG_IGN);
|
(void) signal(SIGINT, SIG_IGN);
|
||||||
|
|||||||
+29
-24
@@ -1,4 +1,4 @@
|
|||||||
/* SCCS Id: @(#)unixmain.c 3.5 2006/04/01 */
|
/* SCCS Id: @(#)unixmain.c 3.5 2007/01/08 */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -157,29 +157,7 @@ char *argv[];
|
|||||||
* It seems you really want to play.
|
* It seems you really want to play.
|
||||||
*/
|
*/
|
||||||
u.uhp = 1; /* prevent RIP on early quits */
|
u.uhp = 1; /* prevent RIP on early quits */
|
||||||
#ifdef SA_RESTART
|
sethanguphandler((SIG_RET_TYPE)hangup);
|
||||||
/* don't want reads to restart. If SA_RESTART is defined, we know
|
|
||||||
* sigaction exists and can be used to ensure reads won't restart.
|
|
||||||
* If it's not defined, assume reads do not restart. If reads restart
|
|
||||||
* and a signal occurs, the game won't do anything until the read
|
|
||||||
* succeeds (or the stream returns EOF, which might not happen if
|
|
||||||
* reading from, say, a window manager). */
|
|
||||||
{
|
|
||||||
struct sigaction sact;
|
|
||||||
|
|
||||||
(void) memset((char*) &sact, 0, sizeof(struct sigaction));
|
|
||||||
sact.sa_handler = (SIG_RET_TYPE)hangup;
|
|
||||||
(void) sigaction(SIGHUP, &sact, (struct sigaction*)0);
|
|
||||||
#ifdef SIGXCPU
|
|
||||||
(void) sigaction(SIGXCPU, &sact, (struct sigaction*)0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
(void) signal(SIGHUP, (SIG_RET_TYPE) hangup);
|
|
||||||
#ifdef SIGXCPU
|
|
||||||
(void) signal(SIGXCPU, (SIG_RET_TYPE) hangup);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
process_options(argc, argv); /* command line options */
|
process_options(argc, argv); /* command line options */
|
||||||
init_nhwindows(&argc, argv); /* now we can set up window system */
|
init_nhwindows(&argc, argv); /* now we can set up window system */
|
||||||
@@ -519,6 +497,33 @@ whoami() {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sethanguphandler(handler)
|
||||||
|
void FDECL((*handler), (int));
|
||||||
|
{
|
||||||
|
#ifdef SA_RESTART
|
||||||
|
/* don't want reads to restart. If SA_RESTART is defined, we know
|
||||||
|
* sigaction exists and can be used to ensure reads won't restart.
|
||||||
|
* If it's not defined, assume reads do not restart. If reads restart
|
||||||
|
* and a signal occurs, the game won't do anything until the read
|
||||||
|
* succeeds (or the stream returns EOF, which might not happen if
|
||||||
|
* reading from, say, a window manager). */
|
||||||
|
struct sigaction sact;
|
||||||
|
|
||||||
|
(void) memset((genericptr_t)&sact, 0, sizeof sact);
|
||||||
|
sact.sa_handler = (SIG_RET_TYPE)handler;
|
||||||
|
(void) sigaction(SIGHUP, &sact, (struct sigaction *)0);
|
||||||
|
# ifdef SIGXCPU
|
||||||
|
(void) sigaction(SIGXCPU, &sact, (struct sigaction *)0);
|
||||||
|
# endif
|
||||||
|
#else /* !SA_RESTART */
|
||||||
|
(void) signal(SIGHUP, (SIG_RET_TYPE)handler);
|
||||||
|
# ifdef SIGXCPU
|
||||||
|
(void) signal(SIGXCPU, (SIG_RET_TYPE)handler);
|
||||||
|
# endif
|
||||||
|
#endif /* ?SA_RESTART */
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PORT_HELP
|
#ifdef PORT_HELP
|
||||||
void
|
void
|
||||||
port_help()
|
port_help()
|
||||||
|
|||||||
+10
-3
@@ -122,7 +122,7 @@ char *argv[];
|
|||||||
/* used to clear hangup stuff while still giving standard traceback */
|
/* used to clear hangup stuff while still giving standard traceback */
|
||||||
VAXC$ESTABLISH(vms_handler);
|
VAXC$ESTABLISH(vms_handler);
|
||||||
#endif
|
#endif
|
||||||
(void) signal(SIGHUP, (SIG_RET_TYPE) hangup);
|
sethanguphandler(hangup);
|
||||||
|
|
||||||
process_options(argc, argv); /* command line options */
|
process_options(argc, argv); /* command line options */
|
||||||
|
|
||||||
@@ -389,8 +389,8 @@ byebye()
|
|||||||
extern unsigned long FDECL(sys$delprc,(unsigned long *,const genericptr_t));
|
extern unsigned long FDECL(sys$delprc,(unsigned long *,const genericptr_t));
|
||||||
|
|
||||||
/* clean up any subprocess we've spawned that may still be hanging around */
|
/* clean up any subprocess we've spawned that may still be hanging around */
|
||||||
if (dosh_pid) (void) sys$delprc(&dosh_pid, 0), dosh_pid = 0;
|
if (dosh_pid) (void) sys$delprc(&dosh_pid, (genericptr_t)0), dosh_pid = 0;
|
||||||
if (mail_pid) (void) sys$delprc(&mail_pid, 0), mail_pid = 0;
|
if (mail_pid) (void) sys$delprc(&mail_pid, (genericptr_t)0), mail_pid = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */
|
/* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */
|
||||||
@@ -429,6 +429,13 @@ genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
sethanguphandler(handler)
|
||||||
|
void FDECL((*handler), (int));
|
||||||
|
{
|
||||||
|
(void)signal(SIGHUP, (SIG_RET_TYPE)handler);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PORT_HELP
|
#ifdef PORT_HELP
|
||||||
void
|
void
|
||||||
port_help()
|
port_help()
|
||||||
|
|||||||
+4
-3
@@ -1,4 +1,4 @@
|
|||||||
/* SCCS Id: @(#)vmstty.c 3.5 2005/11/19 */
|
/* SCCS Id: @(#)vmstty.c 3.5 2007/01/08 */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
/* tty.c - (VMS) version */
|
/* tty.c - (VMS) version */
|
||||||
@@ -478,14 +478,15 @@ void
|
|||||||
error VA_DECL(const char *,s)
|
error VA_DECL(const char *,s)
|
||||||
VA_START(s);
|
VA_START(s);
|
||||||
VA_INIT(s, const char *);
|
VA_INIT(s, const char *);
|
||||||
if(settty_needed)
|
|
||||||
|
if (settty_needed)
|
||||||
settty((char *)0);
|
settty((char *)0);
|
||||||
Vprintf(s,VA_ARGS);
|
Vprintf(s,VA_ARGS);
|
||||||
(void) putchar('\n');
|
(void) putchar('\n');
|
||||||
VA_END();
|
VA_END();
|
||||||
#ifndef SAVE_ON_FATAL_ERROR
|
#ifndef SAVE_ON_FATAL_ERROR
|
||||||
/* prevent vmsmain's exit handler byebye() from calling hangup() */
|
/* prevent vmsmain's exit handler byebye() from calling hangup() */
|
||||||
(void)signal(SIGHUP, SIG_DFL);
|
sethanguphandler((void FDECL((*),(int)))SIG_DFL);
|
||||||
#endif
|
#endif
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user