Re: [Q] what to do when waitpid() returns ECHILD under signal(SIGCHLD, SIG_IGN)?
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Jun 19, 2006, 23:57 UTC
- Message-ID
- <Pine.LNX.4.64.0606191654590.5498@g5.osdl.org>
- In-Reply-To
- <7vwtbc7ll6.fsf@assigned-by-dhcp.cox.net>
On Mon, 19 Jun 2006, Junio C Hamano wrote:
Show 5 quoted lines
> > Somebody I met last week in Japan reported that the socks client > he uses to cross the firewall to connect to git:// port from his > company environment seems to do signal(SIGCHLD, SIG_IGN) before > spawning git.
Ok, that sounds pretty broken of it.
> We could work this around by having signal(SIGCHLD, SIG_DFL) > upfront in git.c::main(), but I am wondering what the standard > practice for programs that use waitpid() call.
We need the status return, so failing on getting ECHILD is absolutely the right thing to do, because it implies that we don't know what the status could have been.
So we need to reset SIGCHLD back to SIG_DFL (or catch it explicitly).
Whether we want to do that in the main() routine or when we actually do the fork() or whatever is a different issue.
Linus