]> git.ozlabs.org Git - ccan/blobdiff - ccan/daemonize/daemonize.c
antithread, htable, ilog: more misc sanitizer complaints.
[ccan] / ccan / daemonize / daemonize.c
index d4a0420e3182136a00c0d6d30cea4d9a1f8aa4db..ff5807240ae67a4417403c6118db11ca190782b6 100644 (file)
@@ -6,7 +6,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-/* This code is based on Stevens Advanced Programming in the UNIX
+/* This code is based on Stevens' Advanced Programming in the UNIX
  * Environment. */
 bool daemonize(void)
 {
@@ -33,7 +33,8 @@ bool daemonize(void)
        close(0);
 
        /* Session leader so ^C doesn't whack us. */
-       setsid();
+       if (setsid() == (pid_t)-1)
+               return false;
        /* Move off any mount points we might be in. */
        if (chdir("/") != 0)
                return false;