← Back to team overview

touch-packages team mailing list archive

[Bug 1501916] [NEW] pgrep returns 0 when incorrect command line syntax used

 

Public bug reported:

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
                           namespace as <pid>
 --nslist <ns,...>         list which namespaces will be considered for
                           the --ns option.
                           Available namespaces: ipc, mnt, net, pid, user, uts

 -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
ProcVersionSignature: Ubuntu 3.13.0-61.100-generic 3.13.11-ckt22
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..etc.sysctl.conf: 2015-04-28T09:14:08.035779

** Affects: procps (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug trusty

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to procps in Ubuntu.
https://bugs.launchpad.net/bugs/1501916

Title:
  pgrep returns 0 when incorrect command line syntax used

Status in procps package in Ubuntu:
  New

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
                             namespace as <pid>
   --nslist <ns,...>         list which namespaces will be considered for
                             the --ns option.
                             Available namespaces: ipc, mnt, net, pid, user, uts

   -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
  ProcVersionSignature: Ubuntu 3.13.0-61.100-generic 3.13.11-ckt22
  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..etc.sysctl.conf: 2015-04-28T09:14:08.035779

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1501916/+subscriptions