]> granicus.if.org Git - nethack/commitdiff
hangup revisited (trunk only)
authornethack.rankin <nethack.rankin>
Thu, 1 Mar 2007 03:33:12 +0000 (03:33 +0000)
committernethack.rankin <nethack.rankin>
Thu, 1 Mar 2007 03:33:12 +0000 (03:33 +0000)
     More SAFER_HANGUP tweaking.  Delay its kicking in until main command
loop has been reached, and shut if off again once program is terminating.

include/decl.h
src/allmain.c
src/cmd.c
src/end.c
sys/vms/vmsmain.c

index 3c8b85bb73c82f21596cec4f9d334db3e8d1a38d..e72c24da8004a7597227e960f5084f021e94aad6 100644 (file)
@@ -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;
index 356dbc289901e700599c5b7b20ec1b7dd31c4c3f..b951518e0c32d8d94f8d88e8ba303cb460b0dad9 100644 (file)
@@ -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();
index e944301ef565ebf5a2c2af7a3584ac4feb5f1da7..0bc1587767fa5a0256afa1630451bb500b251580 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -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();
 }
index 80b1b5cac8f989325c23a300a52fdf3f63ae440b..d359a71fee1b6958983a590809c39d388f19eed9 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -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);
 }
 
index 3bdb5dcb0f6f24ec6fd2ce3c5c188501207b6b3d..599988d1892c4d2d79c01120d968492786a78408 100644 (file)
@@ -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