Author: tjansen Date: Thu Oct 8 17:57:49 2009 New Revision: 1064 Log: pisa_daemonize: replace stdin, stdout, and stderr with /dev/null Modified: trunk/libpisa/util.c Modified: trunk/libpisa/util.c ============================================================================== --- trunk/libpisa/util.c Thu Oct 8 17:36:46 2009 (r1063) +++ trunk/libpisa/util.c Thu Oct 8 17:57:49 2009 (r1064) @@ -1160,5 +1160,15 @@ if (result > 0) /* parent is done, let the child do the rest */ exit(0); + /* become a process group leader */ setsid(); + + /* point stdin, stdout and stderr to /dev/null so we can't + * accidentially mess up a console */ + close(0); + close(1); + close(2); + result = open("/dev/null", O_RDWR); + dup(result); + dup(result); }