eduardoll has asked for the wisdom of the Perl Monks concerning the following question:
use warnings; use strict; $| = 1; # need either this or to explicitly flush stdout, etc. # before forking print "Content-type: text/plain\n\n"; print "Going to start the fork now\n"; if ( !defined(my $pid = fork())) { print STDERR "fork error\n"; exit(1); } elsif ($pid == 0) { # child close(STDOUT);close(STDIN);close(STDERR); exec('perl main.pl a b c d e'); # lengthy processing } else { # parent print "forked child \$pid= $pid\n"; exit 0; } __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Exec command running in background after a fork
by 1Nf3 (Pilgrim) on May 22, 2009 at 14:19 UTC | |
|
Re: Exec command running in background after a fork
by Bloodnok (Vicar) on May 22, 2009 at 14:30 UTC |