The daemonize library provides a simple interface to write your own daemon for a linux based system.