Tuesday, June 09, 2009

Little Sugar: Things to remember while creating a daemon

While writing a daemon on unix systems. The daemon should not be attached to any
terminals. So make sure the following things hold valid.

chdir '/'

umask 0

Map STDIN to /dev/null
Map STDOUT to your logging system
MAP STRERR to STDOUT

setsid # Make the daemon a session leader

No comments: