nohup in perl

J

justme

hi

is there an equivalent implementation of nohup in perl, something
like system("nohup $command" ) ??

thanks
 
J

Jaap Karssenberg

How about:

sub nohup {
local $SIG{HUP} = 'IGNORE';
my $pid = fork;
if ($pid) { return $pid } # parent
else { # child
#.... command code here
}
}

of course I have no idea what you are trying to do, so I can't really
say if this would be wise to use :)
 
S

Steven N. Hirsch

Jaap said:
How about:

use POSIX;
sub nohup {
local $SIG{HUP} = 'IGNORE';
my $pid = fork;
if ($pid) { return $pid } # parent
else { # child
setsid() or die "Cannot establish session id: $!\n";
#.... command code here
}
}

You probably want to disassociate from the current session ID, per above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top