Patch to restore SIGCHLD (et al) disposition to SIG_DFL in httpd.c before execve() of CGI process

Denys Vlasenko vda.linux at googlemail.com
Wed May 7 02:21:03 PDT 2008


On Wednesday 07 May 2008 04:43, Laurence Withers wrote:
> Hi,
> 
> Busybox httpd sets the disposition of SIGCHLD (and SIGHUP and SIGPIPE) 
> to SIG_IGN. When executing a CGI process, these signal dispositions are 
> inherited by the executed process (see execve(2) for the details, 
> signal handlers in the text being replaced are of course not inherited, 
> but if the disposition has been set to SIG_DFL or SIG_IGN that *is* 
> inherited by the child).
> 
> This caused some hard-to-track-down behaviour in a CGI script where 
> waitpid() would fail with ECHILD even though the child process existed 
> (and of course it worked when I ran it under strace -- which must 
> itself clear the signal dispositions before launching its child 
> process).
> 
> I attach a patch against 1.10.1 which restores the dispositions of the 
> three signals SIGCHLD, SIGHUP and SIGPIPE to SIG_DFL just before the 
> call to execv. These are the only three that can be set to SIG_IGN in 
> httpd.c . This restores the expected behaviour to CGI processes.
> 
> The alternative would be to restore signal handlers in each CGI process 
> that expected them to be SIG_DFL, but that seems counter-intuitive. 
> This is also not required with any other webserver I've worked with.

Applied, thanks!
--
vda


More information about the busybox mailing list