バックグラウンド プロセスの 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 foo
ctrl+c を押した場合にのみ実行されます。
が恋しいのはなぜSIGCHLD
ですか?