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;
eval
{
local $SIG{ALRM} = sub { die "alarm\n" };
alarm($timeout);
system("<perform some action>");
alarm(0);
};
warn if $@ && $@ ne "alarm\n"; # propagate errors
# Did we timeout?
if ($@)
{
print Wtr "$nack";
}
else
{
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,
m
|