Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Creating a perl daemon

by suyashjain (Initiate)
on May 20, 2013 at 13:10 UTC ( [id://1034338]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Creating a perl daemon
in thread Creating a perl daemon

This always works for me.
daemonize(); sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; defined(my $pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; }
I found it by googling.
Suyash Jain suyash@linuxhacks.in http://www.LinuxHacks.in A Blog for Every Windows User,FEEL THE Linux freedom To RULE THE BOX.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found