LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-30-2005, 12:38 PM   #1
miggins
LQ Newbie
 
Registered: Nov 2004
Location: UK
Distribution: Debian, Ubuntu
Posts: 12

Rep: Reputation: 0
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
 
Old 09-02-2005, 02:42 AM   #2
miggins
LQ Newbie
 
Registered: Nov 2004
Location: UK
Distribution: Debian, Ubuntu
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Probs running .jar file via CGI script under Apache blimbo Programming 1 07-22-2004 10:29 AM
Apache Cgi-Bin confguration on debian distro rjcmi Linux - Newbie 2 07-15-2004 08:11 PM
Failed to execute cgi script in Apache!! baby_linu Linux - Newbie 4 06-30-2004 04:23 PM
Apache cgi-script problem palanisaravanan Linux - General 6 02-07-2004 09:41 AM
Apache CGI Problem : Browser not running script Zaknafien Linux - Software 3 12-31-2003 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 05:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration