NAME Daemon::Daemonize - A daemonizer VERSION Version 0.002 SYNOPSIS use Daemon::Daemonize qw/ :all / daemonize( %options, run => sub { # Daemon code in here... } ) # Do some non-daemon stuff here... You can also use it in the traditional way, daemonizing the current process: daemonize( %options ) # Daemon code in here... and use it to check up on your daemon: # In your daemon use Daemon::Daemonize qw/ :all / write_pidfile( $pidfile ) $SIG{INT} = sub { delete_pidfile( $pidfile ) } ... Elsewhere ... use Daemon::Daemonize qw/ :all / # Return the pid from $pidfile if it contains a pid AND # the process is running (even if you don't own it), 0 otherwise my $pid = check_pidfile( $pidfile ) # Return the pid from $pidfile, or undef if the # file doesn't exist, is unreadable, etc. # This will return the pid regardless of if the process is running my $pid = read_pidfile( $pidfile ) DESCRIPTION Daemon::Daemonize is a toolbox for daemonizing processes and checking up on them. It takes inspiration from , MooseX::Daemon, Net::Server::Daemon, and more... Being new, the API is currently fluid, but shouldn't change too much A note about "close => std" If you're having trouble with IPC in a daemon, try closing only STD* instead of everything. This is a workaround for a problem with using "Net::Server" and "IPC::Open3" in a daemonized process USAGE You can use the following in two ways, either importing them: use Daemon::Daemonize qw/ daemonize / daemonize( ... ) or calling them as a class method: use Daemon::Daemonize Daemon::Daemonize->daemonize daemonize( %options ) Daemonize via the current process, according to %options: chdir Change to when daemonizing. Pass undef for *no* chdir. Default is '/' (for avoiding umount difficulty) close