Thanks for your idea.
I quickly do a sh function, maybe we can simplify it but it's work.
#print all the childs, grandson, great-grandson, ... pids
#warning not use it on your father because you create child and this do never return
get_child_pid_rec () {
local pids=
for pid in $*
do
local child_pids=
local child_pids_rec=
child_pids=$(ps -ef | awk -v ppid_p=$pid 'BEGIN { pids = "" } $3 == ppid_p { pids = pids $2 " " } END { print pids }');
if [[ $child_pids ]]
then
child_pids_rec=$(get_child_pid_rec $child_pids);
fi
pids="$pids $child_pids $child_pids_rec";
done
echo -n "$pids "
}
|