Bug 7778 - pgrep, pkill do not match long process names
Summary: pgrep, pkill do not match long process names
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.21.x
Hardware: PC Mac OS
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-07 11:38 UTC by Chris Hiszpanski
Modified: 2017-07-21 20:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Hiszpanski 2015-01-07 11:38:37 UTC
If there is a process running with a long name, e.g. my_long_process_name, pgrep 'my_long_process_name' will not find the process, however, pgrep 'my_long_process' will. This is unexpected behavior.

It appears the pattern is limited to 15 characters. If the process has more characters than this, the process should match if all 15 characters do.
Comment 1 Denys Vlasenko 2017-07-21 20:57:36 UTC
(In reply to Chris Hiszpanski from comment #0)
> It appears the pattern is limited to 15 characters.

That's because of the comm field in linux task struct.

> If the process has more characters than this, the process should match if all 15 characters do.

killall and pidof do such matching. But it's easier there - they perform plain string compare.

pgrep uses regex patterns, not just strings. Matching regex patterns against incomplete strings would be non-trivial.