LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   RH -> Debian migration breaks CGI script under Apache (https://www.linuxquestions.org/questions/debian-26/rh-debian-migration-breaks-cgi-script-under-apache-358539/)

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;

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

miggins 09-02-2005 02:42 AM

OK, for anyone interested, the reason appears here:

http://perl.apache.org/docs/2.0/user...ignal_Handlers

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

m


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