Kill child processes when exit

Hi,
I have parent script which is invoking multiple child scripts. I would want to kill all the child processes before the parent
process exit.

 
> cat ./parent
#!/bin/ksh
while [ condition ]
do
. ./child arg1 &
if [ condition ]; then
break
fi
done

Is there a way to get the process group id for all the child and child sub processes and kill them all ?

If its invoking multiple children then its own PID should be the common PPID of all children...
e.g. here I know I opened all my windows from one, I look for the first and ps grep its PID:

n12:/home/vbe/test/cut $ ps -ef|grep dtterm
     vbe 63242698 20250744   0 18:01:29 pts/12  0:00 grep dtterm
     vbe 65470862 54985206   1   Aug 08  pts/6 10:04 dtterm
n12:/home/vbe/test/cut $ ps -ef|grep 65470862|grep -v grep
     vbe 13238478 65470862   0   Aug 08  pts/7  0:00 /usr/dt/bin/dtksh
     vbe 16449648 65470862   0   Sep 04  pts/5  0:00 /usr/dt/bin/dtksh
     vbe 18677870 65470862   0   Aug 08  pts/3  0:00 /usr/dt/bin/dtksh
     vbe 20250744 65470862   1   Aug 13 pts/12  0:01 /usr/dt/bin/dtksh
     vbe 22610134 65470862   0   Aug 29  pts/0  0:00 /usr/dt/bin/dtksh
     vbe 38142314 65470862   0   Aug 13 pts/13  0:00 /usr/dt/bin/dtksh
     vbe 43581906 65470862   0   Aug 23  pts/2  0:00 dtksh
     vbe 52035856 65470862   0   Aug 13 pts/11  0:00 /usr/dt/bin/dtksh
     vbe 61800890 65470862   0   Aug 08  pts/8  0:00 /usr/dt/bin/dtksh
     vbe 62718426 65470862   0   Aug 13 pts/10  0:00 /usr/dt/bin/dtksh
     vbe 65470862 54985206   2   Aug 08  pts/6 10:04 dtterm
1 Like

thanks

kill with a pid of zero will signal every process in the current process group.

Regards,
Alister