in reply to Detached forking in a CGI script
I'm not sure fork is the right tool here. I recently came across an easy to use module to put things in the background, Proc::Background that may help (cross-platform even).
use warnings; use strict; use Proc::Background; my @cmd = qw(perl sleep.pl); my $proc = Proc::Background->new(@cmd); my $pid = $proc->pid; print "*** $pid ***\n";
Output showing parent exits while proc still running:
~/scratch$ perl proc.pl *** 3489 *** ~/scratch$ ps ax | grep sleep 3489 pts/1 S 0:00 perl sleep.pl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Detached forking in a CGI script
by queldor (Acolyte) on Apr 29, 2016 at 17:49 UTC | |
by stevieb (Canon) on Apr 29, 2016 at 22:08 UTC | |
by queldor (Acolyte) on Apr 30, 2016 at 00:19 UTC |