hangup revamp (trunk only)
[See cvs log for src/cmd.c for more complete description.]
This turns clearlocks() into a no-op during the period when the UNIX
port is asking the user to confirm whether to overwrite an existing game.
Also, this removes the duplication of code and function between hangup()
and end_of_input(), and it simplifies the check for whether hangups are
supported by adding new macro HANGUPHANDLING. (I don't think global.h is
the best place to be defining that but I couldn't figure out where else
it would fit, other than repeating for individual xxxconf.h files.) And
adds a couple more done_hup checks to try to cope with situations where
rhack() is being bypassed. Lastly, having readchar() return EOF was
ignored for non-UNIX configs; now everybody gets ESC instead of letting
EOF be seen further inside the core.
This commit is contained in:
@@ -157,6 +157,7 @@ char *argv[];
|
||||
* It seems you really want to play.
|
||||
*/
|
||||
u.uhp = 1; /* prevent RIP on early quits */
|
||||
program_state.preserve_locks = 1;
|
||||
sethanguphandler((SIG_RET_TYPE)hangup);
|
||||
|
||||
process_options(argc, argv); /* command line options */
|
||||
@@ -212,6 +213,7 @@ char *argv[];
|
||||
getlock();
|
||||
}
|
||||
#endif /* WIZARD */
|
||||
program_state.preserve_locks = 0; /* after getlock() */
|
||||
|
||||
dlb_init(); /* must be before newgame() */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)unixunix.c 3.5 1994/11/07 */
|
||||
/* SCCS Id: @(#)unixunix.c 3.5 2007/01/12 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -71,6 +71,7 @@ eraseoldlocks()
|
||||
{
|
||||
register int i;
|
||||
|
||||
program_state.preserve_locks = 0; /* not required but shows intent */
|
||||
/* cannot use maxledgerno() here, because we need to find a lock name
|
||||
* before starting everything (including the dungeon initialization
|
||||
* that sets astral_level, needed for maxledgerno()) up
|
||||
|
||||
@@ -379,11 +379,7 @@ whoami()
|
||||
static void
|
||||
byebye()
|
||||
{
|
||||
/* Different versions of both VAX C and GNU C use different return types
|
||||
for signal functions. Return type 'int' along with the explicit casts
|
||||
below satisfy the most combinations of compiler vs <signal.h>.
|
||||
*/
|
||||
int (*hup)();
|
||||
void FDECL((*hup), (int));
|
||||
#ifdef SHELL
|
||||
extern unsigned long dosh_pid, mail_pid;
|
||||
extern unsigned long FDECL(sys$delprc,(unsigned long *,const genericptr_t));
|
||||
@@ -394,10 +390,15 @@ byebye()
|
||||
#endif
|
||||
|
||||
/* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */
|
||||
hup = (int(*)()) signal(SIGHUP, SIG_IGN);
|
||||
hup = (void FDECL((*),(int))) signal(SIGHUP, SIG_IGN);
|
||||
if (!program_state.exiting++ &&
|
||||
hup != (int(*)()) SIG_DFL && hup != (int(*)()) SIG_IGN)
|
||||
(void) (*hup)();
|
||||
hup != (void FDECL((*),(int))) SIG_DFL &&
|
||||
hup != (void FDECL((*),(int))) SIG_IGN) {
|
||||
(*hup)(SIGHUP);
|
||||
#ifdef SAFERHANGUP
|
||||
end_of_input();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CHDIR
|
||||
(void) chdir(getenv("PATH"));
|
||||
|
||||
Reference in New Issue
Block a user