]> granicus.if.org Git - nethack/commitdiff
several hangup tweaks (trunk only)
authornethack.rankin <nethack.rankin>
Thu, 1 Feb 2007 06:15:04 +0000 (06:15 +0000)
committernethack.rankin <nethack.rankin>
Thu, 1 Feb 2007 06:15:04 +0000 (06:15 +0000)
     NOSAVEONHANGUP isn't documented anywhere.  I don't see why it should
wipe out recoverable level files just because it doesn't want to build a
save file out of them during the hangup.  Leave them intact if checkpoint
is active.  If someone really wants to make them always go away, they'll
need to disable INSURANCE as well as enable NOSAVEONHANGUP.

     tty's getret() -> xwaitforspace() could get stuck in a loop after
hangup, depending upon the state of terminal shutdown (accepting EOF or
ESC cares about cbreak mode?).  Make xwaitforspace() become a no-op during
hangup processing.

     vms's call to hangup() from an exit handler took place after the
terminal has been reset (the exit handler for the latter is registered
later so executes sooner).  Then exit_nhwindows() resulted in a second tty
reset attempt and settty() -> setctty() encountered an error (which it
reported, triggeting a getret() call).  Make the vms code correctly guard
against multiple resets.

src/cmd.c
sys/vms/vmstty.c
win/tty/getline.c

index e123aeb86b0c3e5f08bc81221bd6df0cdd54f4a5..adc81a50a153a6ad41eab199600cdbfb89bee35b 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -2825,13 +2825,18 @@ void
 end_of_input()
 {
 # ifdef NOSAVEONHANGUP
-       program_state.something_worth_saving = 0;
+#  ifdef INSURANCE
+       if (flags.ins_chkpt && program_state.something_worth_saving)
+           program_statue.preserve_locks = 1;  /* keep files for recovery */
+#  endif
+       program_state.something_worth_saving = 0;       /* don't save */
 # endif
+
 # ifndef SAFERHANGUP
        if (!program_state.done_hup++)
 # endif
            if (program_state.something_worth_saving) (void) dosave0();
-       exit_nhwindows((char *)0);
+       if (iflags.window_inited) exit_nhwindows((char *)0);
        clearlocks();
        terminate(EXIT_SUCCESS);
        /*NOTREACHED*/  /* not necessarily true for vms... */
index 8f54e3d85f80f2cacccc56afb7ce263666e112e5..c4b4aa0098643b18d07c4095c8cb0b4d0236679a 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)vmstty.c   3.5     2007/01/08      */
+/*     SCCS Id: @(#)vmstty.c   3.5     2007/01/31      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 /* tty.c - (VMS) version */
@@ -375,8 +375,9 @@ void
 settty(s)
 const char *s;
 {
-       if (!bombing) end_screen();
-       if (s) raw_print(s);
+    if (!bombing) end_screen();
+    if (s) raw_print(s);
+    if (settty_needed) {
        disable_broadcast_trapping();
 #if 0          /* let SMG's exit handler do the cleanup (as per doc) */
 /* #ifndef USE_QIO_INPUT */
@@ -392,6 +393,7 @@ const char *s;
        setctty();
 
        settty_needed = FALSE;
+    }
 }
 
 /* same as settty, with no clearing of the screen */
index 6987cd7c4c69a903bac7aa991d73e330cadf5318..6eb8e028e1ebb7a90407fd4a914bce69e3240591 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)getline.c  3.5     2002/10/06      */
+/*     SCCS Id: @(#)getline.c  3.5     2007/01/31      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -226,6 +226,9 @@ register const char *s;     /* chars allowed besides return */
     register int c, x = ttyDisplay ? (int) ttyDisplay->dismiss_more : '\n';
 
     morc = 0;
+#ifdef HANGUPHANDLING
+    if (program_state.done_hup) return;
+#endif
 
     while((c = tty_nhgetch()) != '\n') {
        if(iflags.cbreak) {