* Handle deleted binaries in pidof (was local bug #34992)

This commit is contained in:
Werner Fink 2012-03-16 16:46:06 +00:00
parent d1a0609ab0
commit 99a0a2583f
2 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,7 @@
sysvinit (2.89dsf) UNRELEASED; urgency=low sysvinit (2.89dsf) UNRELEASED; urgency=low
[ Werner Fink ] [ Werner Fink ]
* Handle deleted binaries in pidof (was local bug #34992)
* Allow init to delte extra environment variables (was local bug * Allow init to delte extra environment variables (was local bug
#35858) #35858)
* Avoid that init double environment variables for its childs * Avoid that init double environment variables for its childs

View File

@ -638,8 +638,32 @@ int readproc(int do_stat)
if ((p->nfs = check4nfs(path, buf))) if ((p->nfs = check4nfs(path, buf)))
goto link; goto link;
case DO_STAT: 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->dev = st.st_dev;
p->ino = st.st_ino; p->ino = st.st_ino;