I need to detect when one of my background processes exits. Hence, I installed a trap. run_gui
and run_ai1
are simple exec
functions.
run_gui & gui_pid=$!
run_ai1 & ai1_pid=$!
trap 'echo foo' SIGCHLD
while true; do
echo "Started the loop"
while true; do
read -u $ai1_outfd line || echo "Nothing read"
if [[ $line ]]; then
: # Handle this
fi
done
while true; do
read -u $gui_outfd line || echo "nothing read"
if [[ $line ]]; then
: # Handle this
fi
done
done
When I close the GUI, nothing happens. The echo foo
command is executed only if I press ctrl+c.
Why do I miss the SIGCHLD
?