It might be worth taking a look at the source to Proc::Daemon which also follows the general rules of daemon processes described by W. Richard Stevens - That is, this module performs the following:
Forks a child and exits the parent process.
Becomes a session leader (which detaches the program from the controlling terminal).
Forks another child process and exits first child. This prevents the potential of acquiring a controlling terminal.
Changes the current working directory to "/" - The importance of which is outlined by Zaxo above.
Clears the file creation mask.
Closes all open file descriptors (rather than just STDIN, STDOUT and STDERR - Important if these have been redirected or duplicated within the parent process).