From: PatR Date: Fri, 10 Feb 2023 23:19:13 +0000 (-0800) Subject: X11_hangup() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a07098b20611f7d21d7b395c16d121d139c4414d;p=nethack X11_hangup() I was looking at backporting an X11 build fix to 3.6 and decided that the hangup handling wasn't correct if SAFERHANGUP is defined (which it is by default). It didn't attempt to perform a hangup save. Also, the handler might return when the X code calling it expected it to not do so. I don't know how to force a hangup within X11 so haven't tested this properly. It works fine when there's no hangup. :-/ --- diff --git a/src/cmd.c b/src/cmd.c index df96c79ff..3f47719ea 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -6317,7 +6317,8 @@ hangup( must continue running longer before attempting a hangup save. */ gp.program_state.done_hup++; /* defer hangup iff game appears to be in progress */ - if (gp.program_state.in_moveloop && gp.program_state.something_worth_saving) + if (gp.program_state.in_moveloop + && gp.program_state.something_worth_saving) return; #endif /* SAFERHANGUP */ end_of_input(); diff --git a/win/X11/winX.c b/win/X11/winX.c index 05d7c2ef9..9ee92a123 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -1515,8 +1515,11 @@ X11_error_handler(String str) { nhUse(str); hangup(1); - nh_terminate(EXIT_FAILURE); +#ifdef SAFERHANGUP /* keeps going after hangup() for '#if SAFERHANGUP' */ + end_of_input(); +#endif /*NOTREACHED*/ + nh_terminate(EXIT_FAILURE); } static int @@ -1524,6 +1527,10 @@ X11_io_error_handler(Display *display) { nhUse(display); hangup(1); +#ifdef SAFERHANGUP /* keeps going after hangup() for '#if SAFERHANGUP' */ + end_of_input(); +#endif + /*NOREACHED*/ /* but not declared NORETURN */ return 0; }