From c06458e1c1822a2c8ff89fbdd29262ca97dd18b1 Mon Sep 17 00:00:00 2001 From: Jesse Date: Wed, 29 Mar 2023 10:34:45 -0300 Subject: [PATCH] Accepted patch from Mark Hindley which avoids clearing realpath information in pidof when trying to find matching executables. --- doc/Changelog | 2 ++ man/pidof.8 | 2 +- src/killall5.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index 62ad2da..1b7f61b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -8,6 +8,8 @@ sysvinit (3.07) released; urgency=low In other words, "pidof /tmp/sleep" and "pidof /usr/bin/sleep" will return the same PIDs when /tmp/sleep is a symbolic link to /usr/bin/sleep. * Fixed memory initialization error in pidof. Fix provided by Markus Fischer. + * Accepted patch from Mark Hindle which avoids clearing realpath information + in pidof when trying to find matching executables. sysvinit (3.06) released; urgency=low diff --git a/man/pidof.8 b/man/pidof.8 index 518b09c..6866cb3 100644 --- a/man/pidof.8 +++ b/man/pidof.8 @@ -94,7 +94,7 @@ that it returns PIDs of running programs that happen to have the same name as the program you're after but are actually other programs. Note that the executable name of running processes is calculated with .BR readlink (2), -so symbolic links to executables will also match. However, symbolic links to symbolic links will not match. +so symbolic links to executables will also match. .PP Zombie processes or processes in disk sleep (states Z and D, respectively) are ignored, as attempts to access the stats of these will sometimes fail. diff --git a/src/killall5.c b/src/killall5.c index 9ab0782..6f7528a 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -740,8 +740,8 @@ PIDQ_HEAD *pidof(char *prog) return NULL; /* Try to stat the executable. */ + memset(real_path, 0, sizeof(real_path)); if ( (prog[0] == '/') && ( realpath(prog, real_path) ) ) { - memset(&real_path[0], 0, sizeof(real_path)); dostat++; }