зеркало из https://github.com/github/putty.git
pty_backend_create: set up SIGCHLD handler earlier.
Mark Wooding points out that when running with the +ut flag, we close pty_utmp_helper_pipe during pty backend setup, which causes the previously forked helper process to terminate. If that termination happens quickly enough, then the code later in pty_backend_create won't have set up the SIGCHLD handler and its pipe yet, so when we get to the main event loop, we'll fail to notice that subprocess waiting to be reaped, and leave it lying around as a zombie. An easy fix is to move the handler and pipe setup to before the code that potentially closes pty_utmp_helper_pipe, so that there isn't a race condition any more.
This commit is contained in:
Родитель
4068416683
Коммит
7ffa6ed41e
17
unix/uxpty.c
17
unix/uxpty.c
|
@ -890,6 +890,15 @@ Backend *pty_backend_create(
|
|||
pty->fds[i].pty = pty;
|
||||
}
|
||||
|
||||
if (pty_signal_pipe[0] < 0) {
|
||||
if (pipe(pty_signal_pipe) < 0) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
cloexec(pty_signal_pipe[0]);
|
||||
cloexec(pty_signal_pipe[1]);
|
||||
}
|
||||
|
||||
pty->seat = seat;
|
||||
pty->backend.vt = &pty_backend;
|
||||
|
||||
|
@ -1250,14 +1259,6 @@ Backend *pty_backend_create(
|
|||
add234(ptys_by_pid, pty);
|
||||
}
|
||||
|
||||
if (pty_signal_pipe[0] < 0) {
|
||||
if (pipe(pty_signal_pipe) < 0) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
cloexec(pty_signal_pipe[0]);
|
||||
cloexec(pty_signal_pipe[1]);
|
||||
}
|
||||
pty_uxsel_setup(pty);
|
||||
|
||||
return &pty->backend;
|
||||
|
|
Загрузка…
Ссылка в новой задаче