IMHO, it would be better to put your report code into another perl
program and execute it.  From what I see from your snippet of code, it's
not important for the parent to know what the child is going, you are
even ignoring SIGCHLD.

Also, at some point in the future (I hope at least) mp2 + threaded mpm's
will become more than alpha (although I already use it extensively but
I'm crazy) and you might want to run you code in it.  Forking under
these circumstances would be a bad.

2c

On Fri, 2003-09-12 at 14:40, Cameron B. Prince wrote:
> Hi all,
> 
> I have a report creation perl script that takes about 15 minutes to run and
> I need to fork it. I tried the code from v1:
> 
>   use strict;
>   use POSIX 'setsid';
>   use Apache::SubProcess;
> 
> 
>   my  = shift;
>   ->send_http_header("text/plain");
> 
>   {CHLD} = 'IGNORE';
>   defined (my  = fork) or die "Cannot fork: \n";
>   if () {
>     print "Parent 25481 has finished, kid's PID: \n";
>   } else {
>       ->cleanup_for_exec(); # untie the socket
>       chdir '/'                or die "Can't chdir to /: ";
>       open STDIN, '/dev/null'  or die "Can't read /dev/null: ";
>       open STDOUT, '>/dev/null'
>           or die "Can't write to /dev/null: ";
>       open STDERR, '>/tmp/log' or die "Can't write to /tmp/log: ";
>       setsid or die "Can't start a new session: ";
> 
>       select STDERR;
>       local $| = 1;
>       warn "started\n";
>       # do something time-consuming
>       sleep 1, warn "sh\n" for 1..20;
>       warn "completed\n";
> 
>       CORE::exit(0); # terminate the process
>   }
> 
> 
> First problem, Apache::SubProcess doesn't seem to contain those methods
> anymore.
> Second problem is open.
> 
> Can anyone tell me the proper way to fork with v2?
> 
> Thanks,
> Cameron
-- 
Richard F. Rebel
[EMAIL PROTECTED]
t. 212.239.0000

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to