Kill all child processes.
Can anyone enlighten me what is wrong whit this script
master.sh
slave.sh
The idea was that master launches few child processes (2 in this example) and when it receives any of kill signals, to kill child processes as well.
It doesn't work, and I don't understand why.
Can anyone enlighten me what is wrong whit this script
master.sh
Code:
#!/bin/sh
echo "master:"
echo $$
./slave.sh 'a' &
./slave.sh 'bb' &
pids=`pgrep -P $$`
echo "pids:"
echo $pids
trap "kill -s 9 $pids" 0 1 2 9 15
wait
slave.sh
Code:
#!/bin/sh
i=0
while [ $i -lt 30 ]; do
echo $1
i=$(($i+1))
sleep 1
done
The idea was that master launches few child processes (2 in this example) and when it receives any of kill signals, to kill child processes as well.
It doesn't work, and I don't understand why.