mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-21 04:55:02 -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:
parent
c74d1e3c6a
commit
116dac29cc
19
unix/uxpty.c
19
unix/uxpty.c
@ -261,13 +261,20 @@ static void cleanup_utmp(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_PTY_PRE_INIT
|
|
||||||
static void sigchld_handler(int signum)
|
static void sigchld_handler(int signum)
|
||||||
{
|
{
|
||||||
if (write(pty_signal_pipe[1], "x", 1) <= 0)
|
if (write(pty_signal_pipe[1], "x", 1) <= 0)
|
||||||
/* not much we can do about it */;
|
/* 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
|
#ifndef OMIT_UTMP
|
||||||
static void fatal_sig_handler(int signum)
|
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
|
/* set the child signal handler straight away; it needs to be set
|
||||||
* before we ever fork. */
|
* before we ever fork. */
|
||||||
putty_signal(SIGCHLD, sigchld_handler);
|
pty_setup_sigchld_handler();
|
||||||
pty->master_fd = pty->slave_fd = -1;
|
pty->master_fd = pty->slave_fd = -1;
|
||||||
#ifndef OMIT_UTMP
|
#ifndef OMIT_UTMP
|
||||||
pty_stamped_utmp = FALSE;
|
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);
|
windowid = get_windowid(pty->frontend);
|
||||||
#endif
|
#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.
|
* Fork and execute the command.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user