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.  :-/
This commit is contained in:
PatR
2023-02-10 15:19:13 -08:00
parent 3ada7caf61
commit a07098b206
2 changed files with 10 additions and 2 deletions

View File

@@ -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();

View File

@@ -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;
}