fix remaining contrived issues re HANGUPHANDLING
This commit is contained in:
@@ -1730,7 +1730,11 @@ static int lockfd = -1; /* for lock_file() to pass to unlock_file() */
|
||||
struct flock sflock; /* for unlocking, same as above */
|
||||
#endif
|
||||
|
||||
#if defined(HANGUPHANDLING)
|
||||
#define HUP if (!gp.program_state.done_hup)
|
||||
#else
|
||||
#define HUP
|
||||
#endif
|
||||
|
||||
#ifndef USE_FCNTL
|
||||
static char *
|
||||
|
||||
@@ -40,7 +40,7 @@ static void zerocomp_bwrite(int, genericptr_t, unsigned int);
|
||||
static void zerocomp_bputc(int);
|
||||
#endif
|
||||
|
||||
#if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32)
|
||||
#if defined(HANGUPHANDLING)
|
||||
#define HUP if (!gp.program_state.done_hup)
|
||||
#else
|
||||
#define HUP
|
||||
@@ -58,7 +58,7 @@ dosave(void)
|
||||
} else {
|
||||
clear_nhwindow(WIN_MESSAGE);
|
||||
pline("Saving...");
|
||||
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.done_hup = 0;
|
||||
#endif
|
||||
if (dosave0()) {
|
||||
|
||||
@@ -193,7 +193,7 @@ bwrite(int fd, const genericptr_t loc, unsigned num)
|
||||
#endif
|
||||
}
|
||||
if (failed) {
|
||||
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
|
||||
#if defined(HANGUPHANDLING)
|
||||
if (gp.program_state.done_hup)
|
||||
nh_terminate(EXIT_FAILURE);
|
||||
else
|
||||
|
||||
@@ -644,7 +644,7 @@ topten(int how, time_t when)
|
||||
gt.toptenwin = create_nhwindow(NHW_TEXT);
|
||||
}
|
||||
|
||||
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
|
||||
#if defined(HANGUPHANDLING)
|
||||
#define HUP if (!gp.program_state.done_hup)
|
||||
#else
|
||||
#define HUP
|
||||
|
||||
@@ -164,9 +164,11 @@ main(int argc, char *argv[])
|
||||
* It seems you really want to play.
|
||||
*/
|
||||
u.uhp = 1; /* prevent RIP on early quits */
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.preserve_locks = 1;
|
||||
#ifndef NO_SIGNAL
|
||||
sethanguphandler((SIG_RET_TYPE) hangup);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
process_options(argc, argv); /* command line options */
|
||||
@@ -237,7 +239,9 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
if (*gp.plname) {
|
||||
getlock();
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.preserve_locks = 0; /* after getlock() */
|
||||
#endif
|
||||
}
|
||||
|
||||
if (*gp.plname && (nhfp = restore_saved_game()) != 0) {
|
||||
|
||||
@@ -74,11 +74,13 @@ eraseoldlocks(void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
#if defined(HANGUPHANDLING)
|
||||
gp.program_state.preserve_locks = 0; /* not required but shows intent */
|
||||
/* cannot use maxledgerno() here, because we need to find a lock name
|
||||
* before starting everything (including the dungeon initialization
|
||||
* that sets astral_level, needed for maxledgerno()) up
|
||||
*/
|
||||
#endif
|
||||
for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) {
|
||||
/* try to remove all */
|
||||
set_levelfile_name(gl.lock, i);
|
||||
|
||||
@@ -104,12 +104,14 @@ static int X11_io_error_handler(Display *);
|
||||
|
||||
static int (*old_error_handler)(Display *, XErrorEvent *);
|
||||
|
||||
#if defined(HANGUPHANDLING)
|
||||
#if !defined(NO_SIGNAL) && defined(SAFERHANGUP)
|
||||
#if XtSpecificationRelease >= 6
|
||||
#define X11_HANGUP_SIGNAL
|
||||
static XtSignalId X11_sig_id;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Interface definition, for windows.c */
|
||||
struct window_procs X11_procs = {
|
||||
@@ -1522,9 +1524,11 @@ static void
|
||||
X11_error_handler(String str)
|
||||
{
|
||||
nhUse(str);
|
||||
#if defined(HANGUPHANDLING)
|
||||
hangup(1);
|
||||
#ifdef SAFERHANGUP /* keeps going after hangup() for '#if SAFERHANGUP' */
|
||||
end_of_input();
|
||||
#endif
|
||||
#endif
|
||||
/*NOTREACHED*/
|
||||
nh_terminate(EXIT_FAILURE);
|
||||
@@ -1534,9 +1538,11 @@ static int
|
||||
X11_io_error_handler(Display *display)
|
||||
{
|
||||
nhUse(display);
|
||||
#if defined(HANGUPHANDLING)
|
||||
hangup(1);
|
||||
#ifdef SAFERHANGUP /* keeps going after hangup() for '#if SAFERHANGUP' */
|
||||
end_of_input();
|
||||
#endif
|
||||
#endif
|
||||
/*NOREACHED*/ /* but not declared NORETURN */
|
||||
return 0;
|
||||
@@ -1765,7 +1771,9 @@ X11_hangup(Widget w, XEvent *event, String *params, Cardinal *num_params)
|
||||
nhUse(params);
|
||||
nhUse(num_params);
|
||||
|
||||
#if defined(HANGUPHANDLING)
|
||||
hangup(1); /* 1 is commonly SIGHUP, but ignored anyway */
|
||||
#endif
|
||||
exit_x_event = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2006,10 +2006,12 @@ x_event(int exit_condition)
|
||||
inptr = (inptr + 1) % INBUF_SIZE;
|
||||
/* pkey(retval); */
|
||||
keep_going = FALSE;
|
||||
} else if (gp.program_state.done_hup) {
|
||||
#if defined(HANGUPHANDLING)
|
||||
} else if (gp.program_state.done_hup) {
|
||||
retval = '\033';
|
||||
inptr = (inptr + 1) % INBUF_SIZE;
|
||||
keep_going = FALSE;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case EXIT_ON_KEY_OR_BUTTON_PRESS:
|
||||
@@ -2025,11 +2027,13 @@ x_event(int exit_condition)
|
||||
/* pkey(retval); */
|
||||
}
|
||||
keep_going = FALSE;
|
||||
} else if (gp.program_state.done_hup) {
|
||||
#if defined(HANGUPHANDLING)
|
||||
} else if (gp.program_state.done_hup) {
|
||||
retval = '\033';
|
||||
inptr = (inptr + 1) % INBUF_SIZE;
|
||||
keep_going = FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
panic("x_event: unknown exit condition %d", exit_condition);
|
||||
|
||||
@@ -1220,7 +1220,11 @@ X11_player_selection_dialog(void)
|
||||
if (plsel_align_radios)
|
||||
free(plsel_align_radios);
|
||||
|
||||
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
X11_exit_nhwindows((char *) 0);
|
||||
nh_terminate(0);
|
||||
@@ -1294,7 +1298,11 @@ X11_player_selection_prompts(void)
|
||||
XtDestroyWidget(popup);
|
||||
free((genericptr_t) choices), choices = 0;
|
||||
|
||||
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
X11_exit_nhwindows((char *) 0);
|
||||
nh_terminate(0);
|
||||
@@ -1363,7 +1371,11 @@ X11_player_selection_prompts(void)
|
||||
XtDestroyWidget(popup);
|
||||
free((genericptr_t) choices), choices = 0;
|
||||
|
||||
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
X11_exit_nhwindows((char *) 0);
|
||||
nh_terminate(0);
|
||||
@@ -1431,7 +1443,11 @@ X11_player_selection_prompts(void)
|
||||
XtDestroyWidget(popup);
|
||||
free((genericptr_t) choices), choices = 0;
|
||||
|
||||
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
X11_exit_nhwindows((char *) 0);
|
||||
nh_terminate(0);
|
||||
@@ -1497,7 +1513,11 @@ X11_player_selection_prompts(void)
|
||||
XtDestroyWidget(popup);
|
||||
free((genericptr_t) choices), choices = 0;
|
||||
|
||||
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
X11_exit_nhwindows((char *) 0);
|
||||
nh_terminate(0);
|
||||
|
||||
Reference in New Issue
Block a user