sysvinit/killproc-2.17.dif

59 lines
1.6 KiB
Plaintext

--- libinit.c
+++ libinit.c 2010-10-27 08:17:06.371926813 +0000
@@ -728,19 +728,21 @@ int pidof (const char * inname, const ch
if (!(flags & (KTHREAD|KSHORT)) && !isscrpt) {
char entry[PATH_MAX+1];
char *realname = NULL;
- const char *name;
+ const char *name = NULL;
boolean found;
- if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) {
- if (errno != EPERM && errno != EACCES)
- goto risky;
- continue;
- }
- entry[rll] = '\0';
- name = handl_buf(entry);
+ if (prefix) {
+ if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) {
+ if (errno != EPERM && errno != EACCES)
+ goto risky;
+ continue;
+ }
+ entry[rll] = '\0';
+ name = handl_buf(entry);
- if (prefix && find_mount(name) != prefix)
- continue;
+ if (find_mount(name) != prefix)
+ continue;
+ }
if (fstatat(dfd, here(d->d_name, "exe"), &pid_st, 0) < 0) {
if (errno != EPERM && errno != EACCES)
@@ -765,12 +767,22 @@ int pidof (const char * inname, const ch
if (strlen(fullname) > PATH_MAX)
continue;
+ if (!name) {
+ if ((rll = readlinkat(dfd, here(d->d_name, "exe"), entry, PATH_MAX)) < 0) {
+ if (errno != EPERM && errno != EACCES)
+ goto risky;
+ continue;
+ }
+ entry[rll] = '\0';
+ name = handl_buf(entry);
+ }
+
if (strncmp(fullname, name, PATH_MAX) == 0) {
found = true;
break;
}
- if ((realname = realpath(name, NULL)) == (char*)0)
+ if ((realname = realpath(fullname, NULL)) == (char*)0)
continue;
if (strncmp(realname, name, PATH_MAX) == 0)