バックグラウンド プロセスの 1 つが終了したことを検出する必要があります。ということで、トラップを設置。run_guiとrun_ai1シンプルなexec機能です。
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
GUI を閉じても何も起こりません。コマンドは、echo fooctrl+c を押した場合にのみ実行されます。
が恋しいのはなぜSIGCHLDですか?