Comment 1 for bug 431813

Revision history for this message
Colin Watson (cjwatson) wrote :

I understand that this is probably inconvenient for you otherwise you wouldn't have filed the bug, but as far as I can tell this is actually behaving as specified.

SIG_IGN doesn't mean "this signal no longer exists as far as this process is concerned"; it means "upon receiving this signal, take no action". Take an example program like this:

#include <signal.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
    struct sigaction sa;
    sa.sa_flags = 0;
    sa.sa_handler = SIG_IGN;
    sigaction(SIGHUP, &sa, NULL);
    pause();
    return 0;
}

If you strace that and send it SIGHUP from another terminal, you'll see that it still receives the signal; it just does nothing with it. By the same token, sigwait() gives you a pending signal, without regard for the *action* that would be taken upon receiving that signal.

By contrast, sigsuspend()'s specification explicitly says that it waits for "delivery of a signal whose action is either to execute a signal-catching function or to terminate the process" (sigwait()'s specification does not have this restriction). So, maybe you could use code more like the following?

    sigset_t mask;
    sigprocmask(SIG_SETMASK, NULL, &mask);
    sigsuspend(&mask);