]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fix pid file removal
authorSage Weil <sage@newdream.net>
Sun, 1 Mar 2009 00:25:29 +0000 (16:25 -0800)
committerSage Weil <sage@newdream.net>
Sun, 1 Mar 2009 00:25:29 +0000 (16:25 -0800)
src/msg/SimpleMessenger.cc

index 35674ec2a1d66007ca94551e3984a31ffaab561b..aee08cc8ad6a9a542ccef5cc696d45fe7e7383e4 100644 (file)
@@ -359,13 +359,17 @@ static void remove_pid_file()
   // only remove it if it has OUR pid in it!
   int fd = ::open(g_conf.pid_file, O_RDONLY);
   if (fd >= 0) {
-    char actual[20], correct[20];
-    sprintf(correct, "%d\n", getpid());
-    ::read(fd, actual, 20);
+    char buf[20];
+    ::read(fd, buf, 20);
     ::close(fd);
+    int a = atoi(buf);
 
-    if (strncmp(actual, correct, 20) == 0)
+    if (a == getpid())
       ::unlink(g_conf.pid_file);
+    else
+      dout(0) << "strange, pid file " << g_conf.pid_file 
+             << " has " << a << ", not expected " << getpid()
+             << dendl;
   }
 }