daemonizing and write_to_pid (taken over from pingpress)
function prototypes