1 #include "../include/fmsdaemon.h"
\r
5 #include <sys/types.h>
\r
8 #include <sys/stat.h>
\r
16 modified from http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize
\r
23 /* already a daemon */
\r
24 if ( getppid() == 1 ) return;
\r
26 /* Fork off the parent process */
\r
31 /* If we got a good PID, then we can exit the parent process. */
\r
36 /* At this point we are executing as the child process */
\r
38 /* Change the file mode mask */
\r
41 /* Create a new SID for the child process */
\r
47 /* Redirect standard files to /dev/null */
\r
48 freopen( "/dev/null", "r", stdin);
\r
49 freopen( "/dev/null", "w", stdout);
\r
50 freopen( "/dev/null", "w", stderr);
\r