gpt4 book ai didi

bash - 进程退出时未传递 SIGCHLD

转载 作者:行者123 更新时间:2023-11-29 09:27:37 26 4
gpt4 key购买 nike

我需要检测我的后台进程之一何时退出。因此,我安装了一个陷阱。 run_guirun_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

最佳答案

Non-interactive shells don't enable job control by default. See if putting 'set -o monitor' at the beginning of the script produces the results you want.

来源:Chet Ramey , GNU Bash 的维护者

关于bash - 进程退出时未传递 SIGCHLD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37552755/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com