-   Debian (
-   -   RH -> Debian migration breaks CGI script under Apache (

miggins 08-30-2005 12:38 PM

RH -> Debian migration breaks CGI script under Apache
I've recently upgraded our webserver from RH 7.3 to Debian "etch", installed Apache 2 and all seems fine, except one CGI script no longer functions correctly even though as far as I can tell I've reproduced the Apache configuration options on the new machine. The script in question forks and sets up a timer in the child, as in the following perl fragment:

use CGI qw(:standard);
use IO::File;
use POSIX ":sys_wait_h";
use Socket;
use Time::Local;

socketpair(Rdr, Wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
or die "socketpair: $!";

# ... non-relevant parts removed ...

if ($pid = fork)
# In parent
close Wtr;
$res = <Rdr>;
close Rdr;
waitpid($pid, &WNOHANG);
elsif (defined $pid)
# In child
close Rdr;

local $SIG{ALRM} = sub { die "alarm\n" };
system("<perform some action>");
warn if $@ && $@ ne "alarm\n"; # propagate errors

# Did we timeout?
if ($@)
print Wtr "$nack";
print Wtr "$ack";

close Wtr;
exit 0;

This worked fine as a CGI script on the old RH box, and will work on the new Debian box from the command line but not when run as a CGI script. In the latter case, the fork occurs, the child sleeps but the alarm in the parent never fires but rather functions as if that eval block is not even there.

Is there some obvious Apache/CGI configuration detail that I should check is enabled to
allow this functionality to perform as required?

Thanks for any help/clues,


miggins 09-02-2005 02:42 AM

OK, for anyone interested, the reason appears here:

So out go signals and in come select + while loop. Groan.


All times are GMT -5. The time now is 01:11 PM.