Fix ubuntu "ignoring return value" warnings.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 5 Jun 2009 07:36:24 +0000 (17:06 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 5 Jun 2009 07:36:24 +0000 (17:06 +0930)
ccan/daemonize/daemonize.c
ccan/daemonize/test/run.c

index 861b0fc79cb961d5754899c23b31f0532f8edd32..ca4aafc8fa99c403b8396dd0d871d3840e536e46 100644 (file)
@@ -24,7 +24,9 @@ bool daemonize(void)
        /* Session leader so ^C doesn't whack us. */
        setsid();
        /* Move off any mount points we might be in. */
-       chdir("/");
+       if (chdir("/") != 0)
+               return false;
+
        /* Discard our parent's old-fashioned umask prejudices. */
        umask(0);
        return true;
index 9802c44237c5c6da482adfc4bde692933229a61a..a471268d3ef172995fd4a0088cd70c9266c75383 100644 (file)
@@ -47,7 +47,9 @@ int main(int argc, char *argv[])
                while (getppid() == pid)
                        sleep(1);
                daemonized.ppid = getppid();
-               write(fds[1], &daemonized, sizeof(daemonized));
+               if (write(fds[1], &daemonized, sizeof(daemonized))
+                   != sizeof(daemonized))
+                       exit(1);
                exit(0);
        }