1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-09 23:28:06 -05:00

Reinstate the SIGCHLD handler in ptermapp.

Detecting that the child process in a pterm has terminated is
important for _any_ kind of pterm, so it's a mistake to put the signal
handler setup _solely_ inside the optional pty_pre_init function which
does the privileged setup and forks off a utmp watchdog process. Now
the signal handler is installed even in the GtkApplication-based
multi-window front end to pterm, meaning it will exist even on OS X.
This commit is contained in:
Simon Tatham 2017-11-25 21:49:31 +00:00
parent c74d1e3c6a
commit 116dac29cc

View File

@ -261,13 +261,20 @@ static void cleanup_utmp(void)
}
#endif
#ifndef NO_PTY_PRE_INIT
static void sigchld_handler(int signum)
{
if (write(pty_signal_pipe[1], "x", 1) <= 0)
/* not much we can do about it */;
}
#endif
static void pty_setup_sigchld_handler(void)
{
static int setup = FALSE;
if (!setup) {
putty_signal(SIGCHLD, sigchld_handler);
setup = TRUE;
}
}
#ifndef OMIT_UTMP
static void fatal_sig_handler(int signum)
@ -433,7 +440,7 @@ void pty_pre_init(void)
/* set the child signal handler straight away; it needs to be set
* before we ever fork. */
putty_signal(SIGCHLD, sigchld_handler);
pty_setup_sigchld_handler();
pty->master_fd = pty->slave_fd = -1;
#ifndef OMIT_UTMP
pty_stamped_utmp = FALSE;
@ -790,6 +797,12 @@ static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
windowid = get_windowid(pty->frontend);
#endif
/*
* Set up the signal handler to catch SIGCHLD, if pty_pre_init
* didn't already do it.
*/
pty_setup_sigchld_handler();
/*
* Fork and execute the command.
*/