I want to monitor only a process and its children processes on htop. Filtering on the name of the parent process lists only the parent process, not its children. How do I show the children processes too?
How to display only a process and its descendant processes on htop?
htop
Under Linux, you can do:htop -p `pstree -p $PID | perl -ne 'push @t, /\((\d+)\)/g; END { print join ,, @t }'`where $PID is the root process. This works as follows:The list of the wanted processes are obtained with pstree, using the -p option to list them with their PID.The output is piped to a Perl script that retrieves the PID's, using a regular expression (here, \((\d+)\)), and outputs them separated with commas.This list is provided as an argument of htop -p.For other OS like Mac OS, you may need to adapt the regular expression that retrieves the PIDs.Note: It is unfortunately not possible to update the list with new children that are spawn later, because once htop has been executed, one cannot do anything else. This is a limitation of htop (current version: 2.0.2).