[busybox][patch] httpd.c - CGI scripts can't fork

Jon Nalley jnalley-lists at nalleynet.com
Thu May 20 20:41:22 UTC 2004


On Wed, 2004-05-19 at 05:49, Vladimir N. Oleynik wrote:
> Jon,
> 
> > Because of the signal(SIGCHLD, SIG_IGN) in openServer() the forked CGI
> > process is unable to catch SIGCHLD and reap it's own children 
> 
> But why?
> 1) If your CGI set signal(SIGCHLD, sigchld_catcher) you can
> control SIGCHLD.

My understanding is that since the parent of the CGI (httpd) has set
signal(SIGCHLD, SIG_IGN) the child (CGI) inherits this and won't catch
the signals.

To give some context - my CGI is a php script.  I found that the
following snippet:

<?php
exec("/bin/true",$output,$return);
?>

always set $return to -1.  The PHP exec() call ultimately uses popen(). 
I believe this was because the CGI was ignoring SIGCHLD (because of the
setting in the parent).  Adding my one line fix before the execv()
solves the problem and should not affect signal handling in the parent,
so the only requirement is that the CGI script cleanup for any children
it may create.

-- 
Jon Nalley <jnalley-lists at nalleynet.com>




More information about the busybox mailing list