Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Creating a perl daemon

by suyashjain (Initiate)
on May 20, 2013 at 13:10 UTC ( #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
Node Status?
node history
Node Type: note [id://1034338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2021-04-22 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?