daemon: Don't ignore failed write to pipe.
authorBen Pfaff <blp@nicira.com>
Fri, 18 Dec 2009 21:46:33 +0000 (13:46 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 4 Jan 2010 17:47:01 +0000 (09:47 -0800)
If the write to the pipe fails here then the parent will think that the
child failed to start up, so the child should oblige it by bailing out.

lib/daemon.c

index c4effa9..9a1be55 100644 (file)
@@ -25,6 +25,7 @@
 #include "fatal-signal.h"
 #include "dirs.h"
 #include "lockfile.h"
+#include "socket-util.h"
 #include "timeval.h"
 #include "util.h"
 
@@ -280,9 +281,14 @@ void
 daemonize_complete(void)
 {
     if (detach) {
-        char c = 0;
+        size_t bytes_written;
+        int error;
+
+        error = write_fully(daemonize_fds[1], "", 1, &bytes_written);
+        if (error) {
+            ovs_fatal(error, "could not write to pipe");
+        }
 
-        ignore(write(daemonize_fds[1], &c, 1));
         close(daemonize_fds[1]);
         setsid();
         if (chdir_) {