daemon: Fix bogus error message in read_pidfile() when pidfile is empty.
authorBen Pfaff <blp@nicira.com>
Wed, 21 Jan 2009 00:33:52 +0000 (16:33 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 21 Jan 2009 00:45:22 +0000 (16:45 -0800)
lib/daemon.c

index 4bef20f..0a3af26 100644 (file)
@@ -277,8 +277,13 @@ read_pidfile(const char *pidfile)
     }
 
     if (!fgets(line, sizeof line, file)) {
-        error = errno;
-        VLOG_WARN("%s: read: %s", pidfile, strerror(error));
+        if (ferror(file)) {
+            error = errno;
+            VLOG_WARN("%s: read: %s", pidfile, strerror(error));
+        } else {
+            error = ESRCH;
+            VLOG_WARN("%s: read: unexpected end of file", pidfile);
+        }
         goto error;
     }