pgrep cannot match some long filenames

Bug #113096 reported by Mike Donovan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
procps (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: procps

pgrep has a bug in trying to match:
- a script with a long filename
- and its filename ends in a number

Example:

name this "myscriptwithalongfilename2"
#!/bin/sh
sleep 100000

chmod u+x myscriptwithalongfilename2
./myscriptwithalongfilename2 &

pgrep myscriptwithalongfilename2
[shows nothing]

ps -eF | grep myscriptwithalongfilename2
[will find the script]

This bug appears in Ubuntu Feisty Fawn.

Revision history for this message
Tom Mortimer-Jones (tom-morty) wrote :

I can replicate this.

It seems to be only seeing the first 15 characters of the script name.

pgrep myscriptwithalo
[shows PID]

pgrep myscriptwithalon
[shows nothing]

Is it using the output from ps -e? This seems to truncate the commands after 15 characters.

Changed in procps:
status: Unconfirmed → Confirmed
Revision history for this message
Mike Donovan (mikedonovan80) wrote : Re: [Bug 113096] Re: pgrep cannot match some long filenames

You too noticed ps -e truncates process names.

At first, I suspected pgrep was a script over "ps -e"
but pgrep is a C executable.

ps and pgrep are both linked to libproc.so:
objdump -x /bin/ps | grep libproc
objdump -x /usr/bin/pgrep | grep libproc
NEEDED libproc-3.2.7.so

Probably/maybe a common function in libproc
has a bug/limitation.

--
Mike

--- Tom Mortimer-Jones <email address hidden> wrote:

> I can replicate this.
>
> It seems to be only seeing the first 15 characters
> of the script name.
>
> pgrep myscriptwithalo
> [shows PID]
>
> pgrep myscriptwithalon
> [shows nothing]
>
> Is it using the output from ps -e? This seems to
> truncate the commands
> after 15 characters.
>
> --
> pgrep cannot match some long filenames
> https://bugs.launchpad.net/bugs/113096
> You received this bug notification because you are a
> direct subscriber
> of the bug.
>

____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/

Revision history for this message
Mike Donovan (mikedonovan80) wrote :

You too noticed ps -e truncates process names.

At first, I suspected pgrep was a script over "ps -e"
but pgrep is a C executable.

ps and pgrep are both linked to libproc.so:
objdump -x /bin/ps | grep libproc
objdump -x /usr/bin/pgrep | grep libproc
NEEDED libproc-3.2.7.so

Probably/maybe a common function in libproc
has a bug/limitation (?).

--
Mike

Revision history for this message
Tom Mortimer-Jones (tom-morty) wrote :

Looking at the man page for pgrep this isn't a bug. Looks like it is the default behaviour for backwards compatibility with the original Solaris version.

NOTES
       The process name used for matching is limited to the 15 characters present in the output of
       /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline.

STANDARDS
       pkill and pgrep were introduced in Sun’s Solaris 7. This implementation is fully compatible.

Changed in procps:
status: Confirmed → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.