Skip to content
Snippets Groups Projects
Commit faa0f7ff authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Use daemon(3) function where available.

svn:r665
parent 71e5ad71
No related branches found
No related tags found
No related merge requests found
......@@ -136,7 +136,7 @@ dnl These headers are not essential
AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h netinet/in.h arpa/inet.h)
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname)
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname daemon)
dnl In case we aren't given a working stdint.h, we'll need to grow our own.
dnl Watch out.
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment