Use "daemon(0, 0);" to make it fork and do all the necessary bits to become a daemon. There are quite a few steps to do like closing stdin/out/err but daemon() does it all for you.

- Trevor