]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
use daemon(3).
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 5 Feb 2009 14:23:24 +0000 (14:23 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 5 Feb 2009 14:23:24 +0000 (14:23 +0000)
git-svn-id: file:///svn/unbound/trunk@1455 be551aaa-1e26-0410-a405-d3ace91eadb9

config.h.in
configure
configure.ac
daemon/unbound.c
doc/Changelog
doc/TODO

index aa7ce2d23834ec0d1bd97f26fd8bbb351e23f4ec..c396b2f400c291fba4439cee63730ea9dcca3fd3 100644 (file)
@@ -28,6 +28,9 @@
 /* Define to 1 if you have the `chroot' function. */
 #undef HAVE_CHROOT
 
+/* Define to 1 if you have the `daemon' function. */
+#undef HAVE_DAEMON
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
index 3d4b28c3042663efbe5b2526bf5a63b262b9fc79..6efbac7ce95668762ad732bdd580ae9566a8376a 100755 (executable)
--- a/configure
+++ b/configure
@@ -25283,7 +25283,8 @@ fi
 
 
 
-for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups
+
+for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups daemon
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_func" >&5
index 91202521b0cecd5fcdaab80534065c82fd303781..5cd331b2bd10d707a0e00ac510b7986283fe6df3 100644 (file)
@@ -854,7 +854,7 @@ AC_CHECK_GETADDRINFO_WITH_INCLUDES
 if test $ac_cv_func_getaddrinfo = no; then
 AC_LIBOBJ([fake-rfc2553])
 fi
-AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups])
+AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups daemon])
 
 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
 if echo $build_os | grep darwin8 > /dev/null; then
index 6c5fb6f2863f203bb4ac7ad76428b5d57f59f1f3..5fc3d62175c0201099770e5885c9b7f8b41a14a7 100644 (file)
@@ -294,6 +294,11 @@ checkoldpid(char* pidfile, int inchroot)
 static void
 detach(void)
 {
+#ifdef HAVE_DAEMON
+       /* use POSIX daemon(3) function */
+       if(daemon(1, 0) != 0)
+               fatal_exit("daemon failed: %s", strerror(errno));
+#else /* no HAVE_DAEMON */
 #ifdef HAVE_WORKING_FORK
        int fd;
        /* Take off... */
@@ -319,6 +324,7 @@ detach(void)
                        (void)close(fd);
        }
 #endif /* HAVE_WORKING_FORK */
+#endif /* HAVE_DAEMON */
 }
 
 /** daemonize, drop user priviliges and chroot if needed */
index bd76d2549bab363fb26aadf42cca48384b2c8013..7e7140d925015a3c7b04091bead7ab13b04814c2 100644 (file)
@@ -15,6 +15,7 @@
          inluded ldns package with the unbound source.  The -I include
          is put before the others, so it avoids bad include files from
          an older ldns install.
+       - daemon(3) posix call is used when available.
 
 4 February 2009: Wouter
        - tag for release 1.2.1.
index fdd2177bbf1b4d6241841536f4bed0f16a9c5144..9484292cb4f0ada56d4507f6dfb2082652f3e81d 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -69,7 +69,6 @@ o unbound_control forward [addr {addr}] | [off]
 o #231: unbound_checkconf options to output config file data.
 o config entry to denote that a zone is to be treated as unsigned (even if 
   a DS exists to higher trust anchor).
-o see if we can use daemon(3), cleaner posix usage.
 o see if we can include the python bindings (contrib).
 o see if we can suport var:value (nospace) by parser.
 o remote control read ssl information while priviledged.