* Handle deleted binaries in pidof (was local bug #34992)
authorDr. Werner Fink <werner@suse.de>
Fri, 16 Mar 2012 16:46:06 +0000 (16:46 +0000)
committerDr. Werner Fink <werner@suse.de>
Fri, 16 Mar 2012 16:46:06 +0000 (16:46 +0000)
git-svn-id: svn://svn.sv.gnu.org/sysvinit/sysvinit/trunk@115 456724a4-4300-0410-8514-c89748c515a2

doc/Changelog
src/killall5.c

index d50f39d0e47d603ff0bde19a2f88d5e2a3ecb5fc..5bc45e8ccae8a4c6b3dab8f6367b85ef4587d828 100644 (file)
@@ -1,6 +1,7 @@
 sysvinit (2.89dsf) UNRELEASED; urgency=low
 
   [ Werner Fink ]
 sysvinit (2.89dsf) UNRELEASED; urgency=low
 
   [ Werner Fink ]
+  * Handle deleted binaries in pidof (was local bug #34992)
   * Allow init to delte extra environment variables (was local bug
     #35858)
   * Avoid that init double environment variables for its childs
   * Allow init to delte extra environment variables (was local bug
     #35858)
   * Avoid that init double environment variables for its childs
index 7d42eccbc379a00b9706218f993b5da6fbd8583d..853acb2d1a2158c27ffb42ffa821158e521217d4 100644 (file)
@@ -638,8 +638,32 @@ int readproc(int do_stat)
                        if ((p->nfs = check4nfs(path, buf)))
                                goto link;
                case DO_STAT:
                        if ((p->nfs = check4nfs(path, buf)))
                                goto link;
                case DO_STAT:
-                       if (stat(path, &st) != 0)
+                       if (stat(path, &st) != 0) {
+                               char * ptr;
+
+                               len = readlink(path, buf, PATH_MAX);
+                               if (len <= 0)
+                                       break;
+                               buf[len] = '\0';
+
+                               ptr = strstr(buf, " (deleted)");
+                               if (!ptr)
+                                       break;
+                               *ptr = '\0';
+                               len -= strlen(" (deleted)");
+
+                               if (stat(buf, &st) != 0)
+                                       break;
+                               p->dev = st.st_dev;
+                               p->ino = st.st_ino;
+                               p->pathname = (char *)xmalloc(len + 1);
+                               memcpy(p->pathname, buf, len);
+                               p->pathname[len] = '\0';
+
+                               /* All done */
                                break;
                                break;
+                       }
+
                        p->dev = st.st_dev;
                        p->ino = st.st_ino;
 
                        p->dev = st.st_dev;
                        p->ino = st.st_ino;