The big point here is that, when initializing anything in a daemon, the same defensive coding guidelines apply here. Be as verbose as possible when writing either to the syslog or your own logs. In order to write to any files (including logs) created by the daemon, the file mode mask (umask) must be changed to ensure that they can be written to or read from properly. V1.0, May 2004 This document shows how to write a daemon in Linux using GCC. Knowledge of Linux and a familiarity with C are necessary to use this document. This HOWTO is Copyright by Devin Watson, under the terms of the BSD License. When it does start, the process is just like any other executable on the system. To make it truly autonomous, a child process must be created where the actual code is executed.
/ if (pid 0) exit(EXIT _SUCCESS / Change the file mode mask / umask(0 By setting the umask to 0, we will have full access to the files generated by the daemon.