daemon: Fix behavior in read_pidfile() when pid file is not locked.
authorBen Pfaff <blp@nicira.com>
Wed, 21 Jan 2009 00:34:11 +0000 (16:34 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 21 Jan 2009 00:45:22 +0000 (16:45 -0800)
lib/daemon.c

index 0a3af26..3b766b5 100644 (file)
@@ -275,6 +275,11 @@ read_pidfile(const char *pidfile)
         VLOG_WARN("%s: fcntl: %s", pidfile, strerror(error));
         goto error;
     }
+    if (lck.l_type == F_UNLCK) {
+        error = ESRCH;
+        VLOG_WARN("%s: pid file is not locked", pidfile);
+        goto error;
+    }
 
     if (!fgets(line, sizeof line, file)) {
         if (ferror(file)) {