"ps -p <pid> -o pid=,..." misbehavior
This bug was originally reported at https://bugs.gentoo.org/555200
Observe the following three variants of the same command. They should have the same output but they don't:
polynomial-c@notebook:~ $ ps p $$ -o pid=,comm=,args= 7899 zsh -zsh polynomial-c@notebook:~ $ ps -p $$ -o pid=,comm=,args= ,comm=,args= 7899 polynomial-c@notebook:~ $ ps --pid $$ -o pid=,comm=,args= 7899 zsh -zsh polynomial-c@notebook:~ $
This bug seems to be available for quite a long time. I could even reproduce it on a SLES11SP3 system with ps from procps-3.2.7
The problem can only be triggered by the following circumstances:
- pid must be submitted using "-p". Neither "p" nor "--pid" can trigger it.
- the output format string must begin with "pid=". Everything else doesn't trigger the bug. So neither "-o comm=,pid=,uid=" nor "-o pid,comm" do trigger it but only "-o pid=,..." notations.