Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Starting a process in the background that lives after perl dies.

by edebill (Scribe)
on Nov 09, 2001 at 04:19 UTC ( [id://124250]=note: print w/replies, xml ) Need Help??


in reply to Re: Starting a process in the background that lives after perl dies.
in thread Starting a process in the background that lives after perl dies.

Don't forget to close STDIN, STDOUT and STDERR, and change pwd to "/" so you don't end up with a background process keeping you from unmounting some filesystem later on. I use the following at daemon start time.
my $pid = fork(); if($pid != 0){ exit 0; } chdir "/"; close STDOUT; close STDERR; close STDIN; POSIX::setsid(); # this takes care of controlling terminals
Stevens covered this pretty well, I think it was "Advanced Programming in the UNIX Environment" or some such.
  • Comment on Re: Re: Starting a process in the background that lives after perl dies.
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-21 11:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found