pgrep returns 0 when incorrect command line syntax used
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
procps (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
my belief is that return code 0 should indicate successful match
from man page:
snip
EXIT STATUS
0 One or more processes matched the criteria.
1 No processes matched.
2 Syntax error in the command line.
3 Fatal error: out of memory etc.
snip
dgarley@TPX61:~$ pgrep cat
2537
2541
dgarley@TPX61:~$ echo $?
0
dgarley@TPX61:~$ # COMMENT notice the return code 0 above, there was a successful match
dgarley@TPX61:~$ pgrep -Z cat
pgrep: invalid option -- 'Z'
Usage:
pgrep [options] <pattern>
Options:
-d, --delimiter <string> specify output delimiter
-l, --list-name list PID and process name
-v, --inverse negates the matching
-w, --lightweight list all TID
-c, --count count of matching processes
-f, --full use full process name to match
-g, --pgroup <id,...> match listed process group IDs
-G, --group <gid,...> match real group IDs
-n, --newest select most recently started
-o, --oldest select least recently started
-P, --parent <ppid,...> match only child processes of the given parent
-s, --session <sid,...> match session IDs
-t, --terminal <tty,...> match by controlling terminal
-u, --euid <id,...> match by effective IDs
-U, --uid <id,...> match by real IDs
-x, --exact match exactly with the command name
-F, --pidfile <file> read PIDs from file
-L, --logpidfile fail if PID file is not locked
--ns <pid> match the processes that belong to the same
--nslist <ns,...> list which namespaces will be considered for
-h, --help display this help and exit
-V, --version output version information and exit
For more details see pgrep(1).
dgarley@TPX61:~$ echo $?
0
dgarley@TPX61:~$ # COMMENT notice return code 0 above even though no match (Intentionally used invalid command switch -Z)
dgarley@TPX61:~$
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: procps 1:3.3.9-1ubuntu2.2
ProcVersionSign
Uname: Linux 3.13.0-61-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.15
Architecture: amd64
CurrentDesktop: Unity
Date: Thu Oct 1 16:44:54 2015
InstallationDate: Installed on 2014-12-02 (303 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140417)
SourcePackage: procps
UpgradeStatus: No upgrade log present (probably fresh install)
mtime.conffile.