ps: How can i recursively get all child process for a given pid
Problem
How can I get the entire process tree spawned by a given process displayed as a tree and only that tree i.e. no other processes? The output could e.g. look like I couldn't get the desired result purely with parameters to . The following gives the desired result but seems a bit involved: Does anyone have an easier solution?
Error Output
4378 ? Ss 0:10 SCREEN 4897 pts/16 Ss 0:00 \_ -/bin/bash 25667 pts/16 S+ 0:00 | \_ git diff 25669 pts/16 S+ 0:00 | \_ less -FRSX 11118 pts/32 Ss+ 0:00 \_ -/bin/bash 11123 pts/32 S+ 0:00 \_ vi
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: ps: How can i recursively get all child process for a given pid
The is a very good solution, but it is a little bit reticent. I use instead. But not for a ( ) because it prints only the specific process, but for the session ( ). It can print out any information can print in a fancy ASCII art tree defining the option. So my suggestion for this problem: If the process is not a session leader, then a little bit more trick has to be applied: This gets the session id (SID) of the current process first and then call ps again with that sid. If the column headers a…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix