[PATCH] pgrep: fix -a without -f

Alyssa Ross hi at alyssa.is
Mon Sep 19 18:46:01 UTC 2022


If I run the following:

	sleep inf &
	pgrep -a sleep

I'd expect a result like:

	./busybox pgrep -a sleep
	3955 sleep inf

(That's the result I get from procps's pgrep.)
But prior to this patch, I'd actually get:

	./busybox pgrep -a sleep
	3955 sleep

This happened because the processes' full argv was only being read if
-f was passed, but -a also needs it to be read so it can print it.
---
 procps/pgrep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/procps/pgrep.c b/procps/pgrep.c
index 6d25c247e..b8fbb445d 100644
--- a/procps/pgrep.c
+++ b/procps/pgrep.c
@@ -144,7 +144,7 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
 		sid2match = getsid(pid);
 
 	scan_mask = PSSCAN_COMM | PSSCAN_ARGV0;
-	if (OPT_FULL)
+	if (OPT_LISTFULL || OPT_FULL)
 		scan_mask |= PSSCAN_ARGVN;
 
 	/* One pattern is required, if no -s and no -P */
-- 
2.37.1



More information about the busybox mailing list