Skip to content

pgrep: pattern length check generates an incorrect warning

Hi,

My distribution (Arch Linux) just updated pgrep to version 3.3.13 and I'm getting a new warning that I believe is incorrect.

There is a condition in select_procs() which checks if the pattern's length exceeds 15 characters.

However, this check is only valid if the pattern contains no metacharacters (the user is asking for a direct match).

This check was added at 4a7f9fca.

For instance, using pgrep to search for multiple non-existent processes produces this warning on 3.3.13:

$ pgrep 'undeuxun|blabla|foo|bar'
pgrep: pattern that searches for process name longer than 15 characters will result in zero matches
Try `pgrep -f' option to match against the complete command line.

Every process name in that regular expression is legal and I don't get any warning using 3.3.10 on another machine.

Let me know if you would accept a patch to remove that warning and/or only emit it when there are no metacharacters in the pattern.

Thanks!