NAME

Proc::Daemon - Run Perl programs as daemon process

SYNOPSIS

use Proc::Daemon;
$sess_id = Proc::Daemon::init;

## ... your code here ...

DESCRIPTION

This module contains the routine init which can be called by a perl program to initialize itself as a daemon. The routine achieves this by the following:

  1. Forks a child and exits the parent process.

  2. Becomes a session leader (which detaches the program from the controlling terminal).

  3. Changes the current working directory to "/".

  4. Clears the file creation mask.

The calling program is responible for closing unnecessary open file handles.

The return value is the session id returned from setsid().

If an error occurs in init so it cannot perform the above steps, than it croaks with an error message. One can prevent program termination by using eval.

AUTHOR

Earl Hood, ehood@medusa.acs.uci.edu

http://www.oac.uci.edu/indiv/ehood/