tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: wait(2) and SIGCHLD



On Sat, Aug 15, 2020 at 07:24:01AM -0400, Mouse wrote:
 > >>> What I observe is that a process that explicitly ignores SIGCHLD
 > >>> (SIG_IGN), then forks a child which exits, when wait()ing for the
 > >>> child, gets ECHILD (i.e., wait returns -1 and errno is ECHILD).
 > >> And the ECHILD return is delayed until all children have terminated
 > > Huh, I hadn't realized (or expected) that.  So I guess it's wrong to
 > > implement this by just detaching the child up front...?
 > 
 > I would say so, especially since that would mean the child's parent is
 > no longer the process that forked it (which could break other use
 > cases).

That depends on how you implement detaching, but I suppose ultimately
it's important for getppid() to revert to 1 at the point the parent
exits (neither before, nor after, nor never) so some kind of linkage
needs to remain.

Bah.

I guess it's time to invent yet another different interface to
fork-and-really-detach.

 > > I'm guessing also then that it's the signal setting when the child
 > > exits that matters; I had always thought it was the signal setting
 > > when the child was forked.
 > 
 > Oh, interesting point.
 > 
 > Yes, in a test I just did [...]

Yup, me too.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index