Re: [PATCH] pgrep: make --terminal respect other criteria
"Jason Cox" <[email protected]> ("me") Tue, 24 Jan 2023 15:56:13 -0500
| Newsgroups | gmane.linux.procps.devel |
|---|---|
| Message-ID | <CQ0PY73B7490.SGXZ29KRAONX@ramon> |
Hi, Just bumping this patch since it's been several weeks since I submitted it and I haven't heard anything despite other activity on the mailing list. Let me know if I need to submit elsewhere or update the patch. On Fri Dec 9, 2022 at 1:33 PM EST, Jason Cox wrote: > --- > > I discovered today that in some cases the --terminal option to pgrep > will cause all processes matching the terminal to be output, even if > other criteria would exclude them. Specifically, I noticed that it > overrides the --runstates option. This simple patch fixes it for me. > > src/pgrep.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/pgrep.c b/src/pgrep.c > index eeebf3e8..eec67361 100644 > --- a/src/pgrep.c > +++ b/src/pgrep.c > @@ -685,8 +685,8 @@ static struct el * select_procs (int *num) > match =3D 0; > else if (opt_older && (int)PIDS_GETFLT(ELAPSED) < opt_older) > match =3D 0; > - else if (opt_term) > - match =3D match_strlist(PIDS_GETSTR(TTYNAME), opt_term); > + else if (opt_term && ! match_strlist(PIDS_GETSTR(TTYNAME), opt_t= erm)) > + match =3D 0; > else if (opt_runstates && ! strchr(opt_runstates, PIDS_GETSCH(ST= A))) > match =3D 0; > else if (opt_cgroup && ! match_cgroup_list (PIDS_GETSTV(CGROUP),= opt_cgroup)) > --=20 > 2.38.1 --=20 Jason Cox jasoncarloscox.com