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

Laurence Withers l at lwithers.me.uk
Tue May 6 19:43:59 PDT 2008


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.

Bye for now,
-- 
Laurence Withers, <l at lwithers.me.uk>
http://www.lwithers.me.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-1.10.1-httpd-restore-SIG_DFL.patch
Type: text/x-diff
Size: 408 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20080507/9d48bb74/attachment.patch 


More information about the busybox mailing list