Bug 7778

Summary: pgrep, pkill do not match long process names
Product: Busybox Reporter: Chris Hiszpanski <chiszp>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: minor CC: busybox-cvs, wmy_ld
Priority: P5    
Version: 1.21.x   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Host: Target:
Build:

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.