[git commit] pidof: support "pidof /path/to/binary" case
Denys Vlasenko
vda.linux at googlemail.com
Sat Jun 15 16:35:39 UTC 2019
commit: https://git.busybox.net/busybox/commit/?id=3a0eea0887d72f28d13d329be90fe4082cbbd427
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
find_pid_by_name 230 227 -3
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libbb/find_pid_by_name.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c
index abbf293e8..fe13f7211 100644
--- a/libbb/find_pid_by_name.c
+++ b/libbb/find_pid_by_name.c
@@ -90,7 +90,11 @@ pid_t* FAST_FUNC find_pid_by_name(const char *procName)
/* or we require argv0 to match (essential for matching reexeced /proc/self/exe)*/
|| (p->argv0 && strcmp(bb_basename(p->argv0), procName) == 0)
/* or we require /proc/PID/exe link to match */
- || (p->exe && strcmp(bb_basename(p->exe), procName) == 0)
+ || (p->exe && strcmp(
+ procName[0] == '/' ? p->exe /* support "pidof /path/to/binary" case too */
+ : bb_basename(p->exe),
+ procName
+ ) == 0)
) {
pidList = xrealloc_vector(pidList, 2, i);
pidList[i++] = p->pid;
More information about the busybox-cvs
mailing list