Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Answer: Is it possible to background a perl script from within itself?

by hbo (Monk)
on Apr 18, 2003 at 06:09 UTC ( [id://251396]=note: print w/replies, xml ) Need Help??


in reply to Re: Is it possible to background a perl script from within itself?
in thread Is it possible to background a perl script from within itself?

You have to setsid too, to disassociate from your parent's process group:
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(setsid);

# Become a daemon
my $pid=fork;
exit if $pid; # Parent exits here
die "Couldn't fork $!" unless defined($pid);
die "Couldn't start new session $!" unless POSIX::setsid();

# Do your daemon bit...
  • Comment on Re: Answer: Is it possible to background a perl script from within itself?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://251396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found