SUS actually leaves this (immedidately discarding ignored signals)
unspecified and at least on the two systems where I tested this (running
Linux 3.2.9 and Linux 2.6.36.4), this program
----------
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
static void child(void)
{
sleep(1);
fputs("\tchild going down\n", stderr);
_exit(0);
}
static void dummy(int unused)
{}
int main(void)
{
sigset_t wanted;
int sig;
sigemptyset(&wanted);
sigaddset(&wanted, SIGINT);
sigaddset(&wanted, SIGCHLD);
sigprocmask(SIG_BLOCK, &wanted, NULL);
if (fork() == 0) child();
sigwait(&wanted, &sig);
fprintf(stderr, "got signal %d\n", sig);
signal(SIGCHLD, dummy);
if (fork() == 0) child();
sigwait(&wanted, &sig);
fprintf(stderr, "got signal %d\n", sig);
return 0;
}
------------
does indicate that a SIGCHLD was received in both cases. I remember
running into lost SIGCHLDs in the past, though, that's why I started to
install dummy handlers for everything I wanted to handle via
sigwaitsomething.