[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "wait" loses signals

From: Denys Vlasenko
Subject: Re: "wait" loses signals
Date: Mon, 24 Feb 2020 18:19:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 2/24/20 5:18 PM, Chet Ramey wrote:
The first case is trickier: there's always going to be a window between
the time the shell checks for pending traps and the time the wait builtin
starts to run. You can't really close it unless you're willing to run the
trap out of the signal handler, which everyone agrees is a bad idea, but
you can squeeze it down to practially nothing.

dash uses something along these lines:

        sigprocmask(SIG_SETMASK, &mask, &mask);
        while (!pending_sig)
        sigprocmask(SIG_SETMASK, &mask, NULL);
        if (pending_sig)
        pid = waitpid(... WNOHANG);

It sleeps in sigsuspend(), not in waitpid(). This way we wait for both
signals *and* children (by virtue of getting SIGCHLD for them).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]