Hi all...

Sorry about the previous message getting screwed up... Not sure what
happened...

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.

Does anyone have ideas as to how to solve this?


Thanks,
Cameron


Reply via email to