Stas Bekman
Tue, 16 Sep 2003 01:18:44 -0700
I have a report generator program written in Perl that I need to start from a CGI. The program takes about 15 minutes to run, so I must fork or double fork. I have two goals:
1) Have no zombies when the program completes 2) Fork in such a way that restarting Apache doesn't kill the forked process.
I tried out the code here which is for mod_perl v1:
http://perl.apache.org/docs/1.0/guide/performance.html#Forking_and_Executing _Subprocesses_from_mod_perl
There are two problems with the code listed in the example:
1) Apache::SubProcess doesn't seem to contain the same methods as the older version.
2) open isn't working. (I've already been down this road and switched another call to an external program to use IPC::Run, but that program doesn't take long and needs no fork.)
I took out the parts of the code that caused problems and ended up with this:
$SIG{CHLD} = 'IGNORE'; defined (my $pid = fork) or die "Cannot fork: $!\n"; unless ($pid) { exec $command; CORE::exit(0); }
This works and accomplishes my first goal, but not the second. If I start the program and restart Apache, the program is killed.
have you detached the session as explained here? http://perl.apache.org/docs/1.0/guide/performance.html#Detaching_the_Forked_Process
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com