How to get child process from parent process
I've written a script to get all child process pids of a parent process. Here is the code. Hope it will help.
function getcpid() {
cpids=`pgrep -P $1|xargs`
# echo "cpids=$cpids"
for cpid in $cpids;
do
echo "$cpid"
getcpid $cpid
done
}
getcpid $1
Just use :
pgrep -P $your_process1_pid
To get the child process and thread,
pstree -p PID
.
It also show the hierarchical tree
I am not sure if I understand you correctly, does this help?
ps --ppid <pid of the parent>