How to get child process from parent process How to get child process from parent process linux linux

How to get child process from parent process


Just use :

pgrep -P $your_process1_pid


I am not sure if I understand you correctly, does this help?

ps --ppid <pid of the parent>


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