SA_NOCLDWAIT and waitXXX strangeties (Was: Re: ports/45972: Perl system() calls will hang if the process has other forked children.)
Anton Berezin <tobez <at> FreeBSD.org>
2002-12-08 17:18:47 GMT
Alan,
On Wed, Dec 04, 2002 at 10:30:02AM -0800, alan wrote:
> The problem is, when you set SA_NOCLDWAIT, subsequent calls to wait()
> (or wait4()) wait for All child processes to exit, not just the
> process ID that wait() is called on. Since Perl's system() calls
> wait4() on its recently forked child, the system() call doesn't return
> until All of the perl process's children exit. This doesn't seem like
> particularly desirable behavior, but it is documented in FreeBSD's
> sigaction man page:
>
> SA_NOCLDWAIT If this bit is set when calling sigaction() for the
> SIGCHLD signal, the system will not create zombie
> processes when children of the calling process
> exit. If the calling process subsequently issues a
> wait(2) (or equivalent), it blocks until all of the
> calling process's child processes terminate, and
> then returns a value of -1 with errno set to
> ECHILD.
I don't like this behavior. Personally, I would like to think that it
should not wait for all children if any of the waitXXX() explicitly
specifies a pid to wait for. Obviously, there is a difference between
how I would like to interpret the docs and the reality. :-/ So in this
particular instance it looks to me like a bug (or at least, a gray area)
in FreeBSD, which should be discussed, hence the copy to arch-.
(The complete description of the problem, for the benefits of arch-
folks, can be found here:
(Continue reading)