suggested fix for the sigchld race

Markus Friedl markus at openbsd.org
Thu Nov 1 06:16:26 EST 2001


On Wed, Oct 31, 2001 at 01:33:38PM -0500, Nicolas Williams wrote:
> Does this make it unnecessary to block SIGCHLD around where
> child_terminated is manipulated? At first glance I'd say yes...

currently, collect_children() blocks signals:

static void
collect_children(void)
{
        pid_t pid;
        sigset_t oset, nset;
        int status;

        /* block SIGCHLD while we check for dead children */
        sigemptyset(&nset);
        sigaddset(&nset, SIGCHLD);
        sigprocmask(SIG_BLOCK, &nset, &oset);
        if (child_terminated) {
                while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
                        session_close_by_pid(pid, status);
                child_terminated = 0;
        }
        sigprocmask(SIG_SETMASK, &oset, NULL);
}



More information about the openssh-unix-dev mailing list