[or-cvs] Use daemon(3) function where available.
Nick Mathewson
nickm at seul.org
Thu Oct 23 14:28:46 UTC 2003
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv5225/src/common
Modified Files:
util.c
Log Message:
Use daemon(3) function where available.
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- util.c 22 Oct 2003 17:25:58 -0000 1.35
+++ util.c 23 Oct 2003 14:28:44 -0000 1.36
@@ -548,7 +548,13 @@
}
void daemonize(void) {
-#ifndef MS_WINDOWS
+#ifdef HAVE_DAEMON
+ if (daemon(0 /* chdir to / */,
+ 0 /* Redirect std* to /dev/null */)) {
+ log_fn(LOG_ERR, "Daemon returned an error: %s", strerror(errno));
+ exit(1);
+ }
+#elif ! defined(MS_WINDOWS)
/* Fork; parent exits. */
if (fork())
exit(0);
More information about the tor-commits
mailing list