As Alexandre Julliard wrote:
The fact that the macro exists doesn't mean it works. Most Linux kernels don't support SA_NOCLDWAIT, even though the symbol may be defined in the headers.
That sounds to be a very stupid mistake to me. Why would one define something one doesn't support? But OK, that's nothing we can change.
I don't have the Posix standard, but at least according to the single Unix spec using SIG_IGN is just as standard as SA_NOCLDWAIT, and a quick grep of the FreeBSD sources seems to indicate that it should work. Did I miss something?
signal() is not part of Posix at all, IIRC. Sure, SIG_IGN has always been defined, but its effect on SIGCHLD didn't used to be defined. When i implemented the FreeBSD SA_NOCLDWAIT feature, i purposely decided to not also implement the SIG_IGN irregularity (SIG_IGN means that the /signal/ is being ignored, but never implied any other side-effect in the past), to remain backwards compatible with the BSD behaviour.
It's still that way, see the following short test program:
j@uriah 720% cat foo.c #include <signal.h> #include <unistd.h> #include <stdlib.h>
void createchild(void) { if (fork() == 0) { exit(0); } }
int main(void) { createchild(); createchild(); createchild(); sleep(1); system("ps"); sleep(2); return 0; } j@uriah 721% make foo cc -O -pipe foo.c -o foo j@uriah 722% ./foo PID TT STAT TIME COMMAND ... 0 p3 ZW+ 0:00.00 (foo) 0 p3 ZW+ 0:00.00 (foo) 0 p3 ZW+ 0:00.00 (foo) 992 p3 Ss 0:02.13 -tcsh (tcsh) 12287 p3 S+ 0:00.00 ./foo 12291 p3 S+ 0:00.00 sh -c ps 12292 p3 R+ 0:00.00 ps ...
Of course, now that i see that SUSP indeed standardized this oddness, i might change my opinion. Anyway, as demonstrated above, signal(SIGCHLD, SIG_IGN) doesn't work on FreeBSD the way you would expect it to work. So Gerald, please at least integrate the patch into the FreeBSD port.