32 #if defined __SUNPRO_C || defined __DECC || defined __HP_cc
33 # pragma ident "@(#)$Header: /cvsroot/wikipedia/willow/src/bin/willow/daemon.c,v 1.1 2005/05/02 19:15:21 kateturner Exp $"
34 # pragma ident "$NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $"
46 int daemonize(
int nochdir,
int noclose)
69 if (noclose == 0 && (fd = open(
"/dev/null", O_RDWR, 0)) != -1) {
70 if(dup2(fd, STDIN_FILENO) < 0) {
74 if(dup2(fd, STDOUT_FILENO) < 0) {
75 perror(
"dup2 stdout");
78 if(dup2(fd, STDERR_FILENO) < 0) {
79 perror(
"dup2 stderr");
83 if (fd > STDERR_FILENO) {