-o comm=
means user output should be the command name only, but without any column title. E.g. if you do -o comm=COMMAND
, it will print you a column title COMMAND
:
$ ps -o comm= -p $PPID
xterm
$ ps -o comm=COMMAND -p $PPID
COMMAND
xterm
-p $PPID
selects the process by the given parent's PID
, the PPID
.
That means -o comm= -p $PPID
are two independent options.
So your command essentially does give you the name of the parent process by its PPID
.
E.g. if I start tmux
, it has the PID
of 1632. Now I start several bash
in each pane, which each have the PPID of 1632, but have their own PID.
You can learn more in What are PID and PPID?
I am not sure, but ps
might look at /proc/$PPID/comm
to determine the parent's command name.
In my case, executing this command gives you the name of the parent's process, without using ps
:
$ cat /proc/$PPID/comm
tmux
$ cat /proc/1632/comm
tmux
ps
just has a switch case that prints out given columns, if the-o
option is given, and a header for each column that has a string following the=
. – polym Jul 21 '14 at 21:02