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:44:14 +0000 (16:44 -0800)
lib/daemon.c

index 38cbc7b2ed940a3dc2c762e0eb2d9d22191b1549..83465493912de40ba2130433fea4c2a7ff608854 100644 (file)
@@ -276,6 +276,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)) {