diff -ru sysvinit-2.86/src/killall5.c sysvinit-2.86-fixed/src/killall5.c --- sysvinit-2.86/src/killall5.c 2005-12-20 15:02:01.000000000 -0500 +++ sysvinit-2.86-fixed/src/killall5.c 2005-12-20 15:01:35.000000000 -0500 @@ -51,9 +51,8 @@ char *argv0base; /* `basename argv[1]` */ char *argv1; /* Name as found out from argv[1] */ char *argv1base; /* `basename argv[1]` */ + char *pathname; /* full path to executable */ char *statname; /* the statname without braces */ - ino_t ino; /* Inode number */ - dev_t dev; /* Device it is on */ pid_t pid; /* Process ID. */ int sid; /* Session ID. */ int kernel; /* Kernel thread or zombie. */ @@ -172,7 +171,6 @@ FILE *fp; PROC *p, *n; struct dirent *d; - struct stat st; char path[256]; char buf[256]; char *s, *q; @@ -191,6 +189,8 @@ n = p->next; if (p->argv0) free(p->argv0); if (p->argv1) free(p->argv1); + if (p->pathname) free(p->pathname); + if (p->statname) free(p->statname); free(p); } plist = NULL; @@ -248,6 +248,7 @@ p->sid = 0; nsyslog(LOG_ERR, "can't read sid from %s\n", path); + if (p->statname) free(p->statname); free(p); continue; } @@ -300,15 +301,18 @@ } else { /* Process disappeared.. */ + if (p->statname) free(p->statname); free(p); continue; } /* Try to stat the executable. */ snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name); - if (stat(path, &st) == 0) { - p->dev = st.st_dev; - p->ino = st.st_ino; + p->pathname = (char *)xmalloc(PATH_MAX); + if (readlink(path, p->pathname, PATH_MAX) == -1) { + p->pathname = NULL; + } else { + p->pathname[PATH_MAX-1] = '\0'; } /* Link it into the list. */ @@ -372,14 +376,14 @@ { PROC *p; PIDQ_HEAD *q; - struct stat st; char *s; int dostat = 0; int foundone = 0; int ok = 0; + char *real_path; /* Try to stat the executable. */ - if (prog[0] == '/' && stat(prog, &st) == 0) dostat++; + if (prog[0] == '/' && (real_path = canonicalize_file_name(prog))) dostat++; /* Get basename of program. */ if ((s = strrchr(prog, '/')) == NULL) @@ -390,10 +394,10 @@ q = (PIDQ_HEAD *)xmalloc(sizeof(PIDQ_HEAD)); q = init_pid_q(q); - /* First try to find a match based on dev/ino pair. */ + /* First try to find a match based on pathname. */ if (dostat) { for (p = plist; p; p = p->next) { - if (p->dev == st.st_dev && p->ino == st.st_ino) { + if (p->pathname && strcmp(real_path, p->pathname) == 0) { add_pid_to_q(q, p); foundone++; } @@ -408,11 +412,14 @@ ok += (p->argv0 && strcmp(p->argv0, prog) == 0); ok += (p->argv0 && strcmp(p->argv0base, s) == 0); + if (prog[0] == '/' && p->pathname && strcmp(prog, p->pathname)) + ok = 0; + /* For scripts, compare argv[1] as well. */ if (scripts_too && p->argv1 && !strncmp(p->statname, p->argv1base, STATNAMELEN)) { ok += (strcmp(p->argv1, prog) == 0); - ok += (strcmp(p->argv1base, s) == 0); + if (prog[0] != '/') ok += (strcmp(p->argv1base, s) == 0); } /*