Public bug reported:

If a command line is really long and the search term is toward the end
of it, pgrep -f fails to find the process. Experimentally, it appears
that the magic number is about 4084.

The script below reproduces the problem. If the command line is short,
pgrep -f reports both a sleep and a bash process. If the line is too
long, pgrep -f only reports the sleep process.


# pgrep -f fails if >= 4063, succeeds if < 4063
stringLength=4063

reallyLongString=$(cat /dev/urandom | tr -cd '[:alnum:]' | head -c 
$stringLength)
bash -c "echo $reallyLongString > /dev/null ; sleep 999" 2> /dev/null&
pid=$!
sleep 1
echo no -f:
pgrep -l sleep
echo with -f:
pgrep -fl sleep

pkill sleep

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

-- 
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/1758087

Title:
  pgrep -f fails for long command lines

Status in procps package in Ubuntu:
  New

Bug description:
  If a command line is really long and the search term is toward the end
  of it, pgrep -f fails to find the process. Experimentally, it appears
  that the magic number is about 4084.

  The script below reproduces the problem. If the command line is short,
  pgrep -f reports both a sleep and a bash process. If the line is too
  long, pgrep -f only reports the sleep process.

  
  # pgrep -f fails if >= 4063, succeeds if < 4063
  stringLength=4063

  reallyLongString=$(cat /dev/urandom | tr -cd '[:alnum:]' | head -c 
$stringLength)
  bash -c "echo $reallyLongString > /dev/null ; sleep 999" 2> /dev/null&
  pid=$!
  sleep 1
  echo no -f:
  pgrep -l sleep
  echo with -f:
  pgrep -fl sleep

  pkill sleep

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

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to