From a7b8b772dee4f159028e3b998454d7466fbbc88f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 11 Jul 2019 14:00:07 -0700 Subject: pidof: fix default behavior, add -x. Before this patch, we're effectively doing `pidof -x` all the time. This patch changes names_to_pid() to allow us to say whether or not we want to include scripts, and adjusts the callers appropriately. Also add tests for `pidof` versus `pidof -x` which pass after this patch, without regressing the existing killall tests. --- toys/lsb/pidof.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys/lsb/pidof.c') diff --git a/toys/lsb/pidof.c b/toys/lsb/pidof.c index 4f266b84..cd705a7c 100644 --- a/toys/lsb/pidof.c +++ b/toys/lsb/pidof.c @@ -5,7 +5,7 @@ * * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/pidof.html -USE_PIDOF(NEWTOY(pidof, "<1so:", TOYFLAG_BIN)) +USE_PIDOF(NEWTOY(pidof, "<1so:x", TOYFLAG_BIN)) config PIDOF bool "pidof" @@ -17,6 +17,7 @@ config PIDOF -s Single shot, only return one pid -o Omit PID(s) + -x Match shell scripts too */ #define FOR_pidof @@ -39,6 +40,6 @@ static int print_pid(pid_t pid, char *name) void pidof_main(void) { toys.exitval = 1; - names_to_pid(toys.optargs, print_pid); + names_to_pid(toys.optargs, print_pid, FLAG(x)); if (!toys.exitval) xputc('\n'); } -- cgit v1.2.3