From fdbc2c9e860a46500b6ddba74b6e383bd0f2e4d4 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 1 Feb 2007 06:15:04 +0000 Subject: [PATCH] several hangup tweaks (trunk only) 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 | 9 +++++++-- sys/vms/vmstty.c | 8 +++++--- win/tty/getline.c | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index e123aeb86..adc81a50a 100644 --- 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... */ diff --git a/sys/vms/vmstty.c b/sys/vms/vmstty.c index 8f54e3d85..c4b4aa009 100644 --- a/sys/vms/vmstty.c +++ b/sys/vms/vmstty.c @@ -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 */ diff --git a/win/tty/getline.c b/win/tty/getline.c index 6987cd7c4..6eb8e028e 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -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) {