Hello,
It's so easy to simulate 'nohup' command in perl script.Usually you just
fork a child,then parent die,go into child,call setsid to get child become
the session leader,re-open the STDIN,STDOUT,STDERR to a null device (for
example '/dev/null'),last call 'exec' or 'system' to do the things for you.
The sample codes are shown as follow:
use strict;
use POSIX qw/setsid/;
my $pid = fork();
die "can't fork: $!" unless defined $pid;
exit 0 if $pid;
setsid();
open (STDIN, "</dev/null");
open (STDOUT, ">/dev/null");
open (STDERR,">&STDOUT");
exec "some_system_command";
and i want to see what is the best way to port the "nohup" shell command in
perl, anyone knows?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>