Bug #3563
closedpgrep(1) -x description could be clearer
100%
Description
From the pgrep man page:
-x Considers only processes whose argument string or executable file name exactly matches the specified pattern to be matching processes. The pattern match is considered to be exact when all characters in the process argument string or executable file name match the pattern.
Observed behaviour:
# pgrep /opt/ec/bin/snapshot_hourly.sh # pgrep -x /opt/ec/bin/snapshot_hourly.sh # ps -ef | grep /opt/ec/bin/snapshot_hourly.sh root 71199 56198 0 10:24:06 pts/3 0:00 /bin/bash /opt/ec/bin/snapshot_hourly.sh root 71587 66659 0 10:24:33 pts/6 0:00 grep /opt/ec/bin/snapshot_hourly.sh
Updated by Alasdair Lumsden about 10 years ago
pargs output:
root ~ (so1-12.ixlon1): pargs 36481 36481: /bin/bash /opt/ec/bin/snapshot_hourly.sh argv[0]: /bin/bash argv[1]: /opt/ec/bin/snapshot_hourly.sh root ~ (so1-12.ixlon1): pgrep -x /opt/ec/bin/snapshot_hourly.sh root ~ (so1-12.ixlon1):
Updated by Yuri Pankov about 10 years ago
Remember that you need -f to match full command line, not just executable name, but it still looks like the documentation is inaccurate here, or rather a bit puzzling (same on FreeBSD), while linux version seems to documents it correctly:
-x Only match processes whose name (or command line if -f is specified) exactly match the pattern.
So the following would have worked for you:
pgrep -fx '/bin/bash /opt/ec/bin/snapshot_hourly.sh'
Updated by Rich Lowe almost 10 years ago
It's saying "executable file name" to try to suggest it matches on the basename, not the full path. That's admittedly not particularly clear. So not only, as Yuri said, is it not matching because of the interpretter, but also because of the full path (both would cause you to need -f)
Updated by Sachidananda Urs about 9 years ago
I propose to change the documentation to reflect the program behavior
sac@hipster:/tmp$ pgrep x emacs-gtk.*'
2544
sac@hipster:/tmp$ pgrep -x /usr/bin/emacs-gtk
sac@hipster:/tmp$ ps 2544
PID TT S TIME COMMAND
2544 ? S 0:41 /usr/bin/emacs-gtk
sac@hipster:/tmp$ pgrep -x 'emacs
2544
sac@hipster:~$ pgrep -x '.macs.*'
2544
sac@hipster:~$
==========
I suggest changing:
x
Considers only processes whose argument
string or executable file name exactly
matches the specified pattern to be match
ing processes. The pattern match is con-
sidered to be exact when all characters in
the process argument string or executable
file name match the pattern.
To
-x
Considers only processes whose executable
file name exactly matches the specified
pattern to the matching processes. The
pattern match is considered to be exact when
all characters in the executable file name
match the pattern.
If I get a couple of ok on this I'll submit a patch for man page.
Updated by Sachidananda Urs about 9 years ago
I propose to change the documentation to reflect the program behavior
sac@hipster:/tmp$ pgrep -x emacs-gtk 2544 sac@hipster:/tmp$ pgrep -x /usr/bin/emacs-gtk sac@hipster:/tmp$ ps 2544 PID TT S TIME COMMAND 2544 ? S 0:41 /usr/bin/emacs-gtk sac@hipster:/tmp$ pgrep -x 'emacs.*' 2544 sac@hipster:~$ pgrep -x '.macs.*' 2544 sac@hipster:~$
I suggest changing:
-x Considers only processes whose argument string or executable file name exactly matches the specified pattern to be match- ing processes. The pattern match is con- sidered to be exact when all characters in the process argument string or executable file name match the pattern.
To
-x Considers only processes whose executable file name exactly matches the specified pattern to the matching processes. The pattern match is considered to be exact when all characters in the executable file name match the pattern.
If I get a couple of ok on this I'll submit a patch for man page.
Updated by Yuri Pankov about 9 years ago
- Category changed from cmd - userland programs to manpage - manual pages
- Tags deleted (
needs-triage)
I still find the linux' description better, as it's far easier to understand than "Considers only processes whose executable file name exactly matches the specified pattern to the matching processes."
Updated by Sachidananda Urs about 9 years ago
Yuri Pankov wrote:
I still find the linux' description better, as it's far easier to understand than "Considers only processes whose executable file name exactly matches the specified pattern to the matching processes."
Yeah I agree too. It is quite short and very much clear. Maybe we should discuss this in the mailing list and come to a conclusion. Can you bring this topic on discuss?
Updated by Sachidananda Urs about 9 years ago
For quick reference, linux man page says:
-x, --exact Only match processes whose name (or command line if -f is specified) exactly match the pattern.
Updated by Sachidananda Urs about 9 years ago
- Status changed from New to Feedback
- Assignee set to Sachidananda Urs
- % Done changed from 0 to 50
Updated by Sachidananda Urs about 9 years ago
- Status changed from Feedback to Pending RTI
Updated by Dan McDonald about 9 years ago
- Subject changed from pgrep not working as documented or documentation inaccurate to pgrep(1) -x description could be clearer
- Status changed from Pending RTI to Resolved
commit c1ca8c1d77967585bfbe78133a7257e36ebfec85
Author: Sachidananda Urs <sacchi@gmail.com>
Date: Wed Jan 15 22:27:07 2014 +0530
3563 pgrep(1) -x description could be clearer
Reviewed by: Marcel Telka <marcel@telka.sk>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
:100644 100644 f4ae7ff... 9e65244... M usr/src/man/man1/pgrep.1