From d6739ada35ce6e0f3182f935606e873e6e06f1bf Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 2 Nov 2002 16:05:26 +0000 Subject: [PATCH] Another signal-handling refinement from RJK: the SIGCHLD handler should be prepared to reap more than one child per invocation if necessary, since we do after all have two. [originally from svn r2183] --- unix/pty.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/unix/pty.c b/unix/pty.c index 8bd20fec..0084e64a 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -168,11 +168,13 @@ static void sigchld_handler(int signum) pid_t pid; int status; - pid = waitpid(-1, &status, WNOHANG); - if (pid == pty_child_pid && (WIFEXITED(status) || WIFSIGNALED(status))) { - pty_exit_code = status; - pty_child_dead = TRUE; - } + do { + pid = waitpid(-1, &status, WNOHANG); + if (pid == pty_child_pid && (WIFEXITED(status) || WIFSIGNALED(status))) { + pty_exit_code = status; + pty_child_dead = TRUE; + } + } while(pid > 0); errno = save_errno; }