* jiffies now ULL in killall SF#3138538
* pstree can show parents of a process. Patch supplied by Curtis
Hawthorne SF#3135157
+ * killall creates right size buffer instead of MAX_PATH Debian #623425
+ * check for /proc/$$/stat not /proc/self/stat which is not available
+ on hurb platforms. Same Debian bug as above
Changes in 22.13
================
/* maybe the binary has been modified and std[j].st_ino
* is not reliable anymore. We need to compare paths.
*/
- char linkbuf[PATH_MAX];
+ size_t len = strlen(namelist[j]);
+ char *linkbuf = malloc(len + 1);
- if (readlink(path, linkbuf, sizeof(linkbuf)) <= 0 ||
- strcmp(namelist[j], linkbuf))
+ if (!linkbuf ||
+ readlink(path, linkbuf, len + 1) != len ||
+ memcmp(namelist[j], linkbuf, len))
ok = 0;
+ free(linkbuf);
}
free(path);
"For more information about these matters, see the files named COPYING.\n"));
}
+static int
+have_proc_self_stat (void)
+{
+ char filename[128];
+ struct stat isproc;
+ pid_t pid = getpid();
+
+ snprintf(filename, sizeof(filename), PROC_BASE"/%d/stat", (int) pid);
+ return stat(filename, &isproc) == 0;
+}
+
int
main (int argc, char **argv)
{
int optc;
int myoptind;
struct passwd *pwent = NULL;
- struct stat isproc;
char yt[16];
char ot[16];
fprintf (stderr, _("Maximum number of names is %d\n"), MAX_NAMES);
exit (1);
}
- if (stat("/proc/self/stat", &isproc)==-1) {
- fprintf (stderr, _("%s is empty (not mounted ?)\n"), PROC_BASE);
+ if (!have_proc_self_stat()) {
+ fprintf (stderr, _("%s lacks process entries (not mounted ?)\n"), PROC_BASE);
exit (1);
}
argv = argv + myoptind;