in reply to Submitting program to background from perl
Here's how to do that in perl without any interference from the shell:
$SIG{CHLD} = 'IGNORE'; { my $cpid = fork; defined $cpid or warn 'Could not fork: ', $! and last; $cpid and last; # child open STDERR, '>>', $errorfile || '/dev/null' or die $!; open STDOUT, '>', $outputfile || '/dev/null' or die $!; open STDIN, '<', $inputfile || '/dev/null' or die $!; $SIG{HUP} = sub {}; exec "/mevs/$version/bin/mevs", "/mevs/$version/data/config_data/mevs2.cfg", 'online'; die $!; } # parent
That does about what nohup does. That can be further refined by imitating how a daemon starts with POSIX::setsid() to declare the child a session leader and remove itself from a controlling terminal.
Shell-like access to a background process is neither necessary or desirable in perl. We have finer weapons than that.
After Compline,
Zaxo
|
|---|