wait3 (waitpid alias) returns -1 with errno set to ECHILD when it should not
TLDR: you are currently relying on unspecified behaviour of signal(2); use sigaction (carefully) instead. Firstly, SIGCHLD is strange. From the manual page for sigaction; POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN. POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD can be used to prevent the creation of zombies (see wait(2)). Nevertheless, the historical … Read more