Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Answer: How do I run a script in the background? How should I run a script as daemon?

by AgentM (Curate)
on Nov 17, 2000 at 01:05 UTC ( [id://42079]=note: print w/replies, xml ) Need Help??


in reply to Re: Answer: How do I run a script in the background? How should I run a script as daemon?
in thread How do I run a script in the background? How should I run a script as daemon?

Why yes, you're right, but our friend, the late W. Richard Stevens goes farther and explains that the best method is as following:
#untested code conversion from C sources exit if fork()!=0; setsid(); $SIG{'HUP'}='IGNORE'; exit if fork()!=0; chdir('/'); #prevents path-specific hax umask(0); #clear file mode creation mask openlog(...); #standard syslog call
With the second call to fork, we are guaranteed that the child is not a session leader and therefore cannot acquire a controlling terminal. We ignore SIGHUP since the session leader is soon to be terminated. Just an expansion on what you said. I certainly admire and trust the late Mr. Stevens very much!
AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
  • Comment on Re: Re: Answer: How do I run a script in the background? How should I run a script as daemon?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-25 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found