aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-10-23 14:28:44 +0000
committerNick Mathewson <nickm@torproject.org>2003-10-23 14:28:44 +0000
commitfaa0f7ffe757043fb1b7ddb7b0643816a554dadc (patch)
treec804e5d62d27d29c8429aff4e0d2ccffc542cbc3 /src
parent71e5ad714bd5c6111d31d1a2879e89d2227cb254 (diff)
downloadtor-faa0f7ffe757043fb1b7ddb7b0643816a554dadc.tar
tor-faa0f7ffe757043fb1b7ddb7b0643816a554dadc.tar.gz
Use daemon(3) function where available.
svn:r665
Diffstat (limited to 'src')
-rw-r--r--src/common/util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c
index a85e22ae8..3d20f8104 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -548,7 +548,13 @@ get_uname(void)
}
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);