in reply to Backgrounding a Program

If you want your process to properly act as a daemon, then the simplest method is to use the Proc::Daemon module:

#!/usr/bin/perl -w use strict; use Proc::Daemon; Proc::Daemon::Init; # your code goes here __END__

This module takes care of all the little things necessary for proper daemonization: as per the docs:

  1. Forks a child and exits the parent process.
  2. Becomes a session leader (which detaches the program from the controlling terminal).
  3. Forks another child process and exits first child. This prevents the potential of acquiring a controlling terminal.
  4. Changes the current working directory to "/".
  5. Clears the file creation mask.
  6. Closes all open file descriptors.