I would like to show a listing of a single process and its current children. So, given the following process tree:
Imagine the following process listing:
PID TTY STAT TIME COMMAND
2 ? S 0:00 [kthreadd]
3 ? S 0:06 \_ [ksoftirqd/0]
...snip...
1292 ? Ss 0:06 /usr/sbin/gpm -m /dev/input/mice -t exps2
1426 ? Ss 0:00 /usr/lib/postfix/master
9785 ? S 0:00 \_ qmgr -l -t fifo -u
12301 ? S 0:00 \_ pickup -l -t fifo -u -c
1545 ? Ss 0:05 /usr/sbin/apache2 -k start
1570 ? S 0:00 \_ /usr/sbin/apache2 -k start
...snip...
I would like to instead just show process 1426 and its children. Like this:
PID TTY STAT TIME COMMAND
1426 ? Ss 0:00 /usr/lib/postfix/master
9785 ? S 0:00 \_ qmgr -l -t fifo -u
12301 ? S 0:00 \_ pickup -l -t fifo -u -c
Is there a simple way to do this?
You can use pstree to do this and get a nicely formatted output too
or:
to display the details command.
The following script displays all processes running under
tmux
:The output looks like this:
For that it recursively calls
ps --ppid ...
.my_pid
stores PID of the script itself, to avoid infinite recursion.level
variable is just in case you need to debug the script.=
inps -o pid=
makes it to not display headers.paste -sd,
turns newline-separated list into a comma-separated one (-d
specifies delimiter, more on it here).tmux display-message
displays server PID (-p
- to stdout).