hangup revisited (trunk only)
More SAFER_HANGUP tweaking. Delay its kicking in until main command loop has been reached, and shut if off again once program is terminating.
This commit is contained in:
@@ -152,9 +152,8 @@ E NEARDATA struct sinfo {
|
||||
#endif
|
||||
int something_worth_saving; /* in case of panic */
|
||||
int panicking; /* `panic' is in progress */
|
||||
#if defined(VMS) || defined(WIN32)
|
||||
int exiting; /* an exit handler is executing */
|
||||
#endif
|
||||
int in_moveloop;
|
||||
int in_impossible;
|
||||
#ifdef PANICLOG
|
||||
int in_paniclog;
|
||||
|
||||
@@ -76,6 +76,7 @@ boolean resuming;
|
||||
youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */
|
||||
context.move = 0;
|
||||
|
||||
program_state.in_moveloop = 1;
|
||||
for(;;) {
|
||||
#ifdef SAFERHANGUP
|
||||
if (program_state.done_hup) end_of_input();
|
||||
|
||||
@@ -2842,6 +2842,7 @@ void
|
||||
hangup(sig_unused) /* called as signal() handler, so sent at least one arg */
|
||||
int sig_unused;
|
||||
{
|
||||
if (program_state.exiting) program_state.in_moveloop = 0;
|
||||
nhwindows_hangup();
|
||||
# ifdef SAFERHANGUP
|
||||
/* When using SAFERHANGUP, the done_hup flag it tested in rhack
|
||||
@@ -2852,7 +2853,8 @@ int sig_unused;
|
||||
must continue running longer before attempting a hangup save. */
|
||||
program_state.done_hup++;
|
||||
/* defer hangup iff game appears to be in progress */
|
||||
if (program_state.something_worth_saving) return;
|
||||
if (program_state.in_moveloop && program_state.something_worth_saving)
|
||||
return;
|
||||
# endif /* SAFERHANGUP */
|
||||
end_of_input();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)end.c 3.5 2007/01/02 */
|
||||
/* SCCS Id: @(#)end.c 3.5 2007/02/28 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1023,6 +1023,7 @@ void
|
||||
terminate(status)
|
||||
int status;
|
||||
{
|
||||
program_state.in_moveloop = 0; /* won't be returning to normal play */
|
||||
#ifdef MAC
|
||||
getreturn("to exit");
|
||||
#endif
|
||||
@@ -1038,6 +1039,7 @@ int status;
|
||||
that would cancel any other pending user-mode handlers */
|
||||
if (program_state.exiting) return;
|
||||
#endif
|
||||
program_state.exiting = 1;
|
||||
nethack_exit(status);
|
||||
}
|
||||
|
||||
|
||||
@@ -375,9 +375,6 @@ byebye()
|
||||
hup != (void FDECL((*),(int))) SIG_DFL &&
|
||||
hup != (void FDECL((*),(int))) SIG_IGN) {
|
||||
(*hup)(SIGHUP);
|
||||
#ifdef SAFERHANGUP
|
||||
end_of_input();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CHDIR
|
||||
|
||||
Reference in New Issue
Block a user