## 复现 ```bash set -euo pipefail awk -F, ... ps aux | head -3 | awk ... # head 退出 → ps 收到 SIGPIPE echo 1 2 3 | xargs ... # 这些之后的命令全部不执行 ``` 多次运行 `niu real2.sh`,约 10% 概率出现: ``` niu rc=141 lines=5 ``` bash 同脚本稳定 14 行 rc=0。 ## 机理 `head` 读满退出后,`ps` 收到 SIGPIPE。bash 管道每个组件独立 fork,`ps` 死不影响父脚本;niu 不 fork,这个 SIGPIPE 直接打到解释器主进程,导致 niu 以 128+13=141 退出,脚本后续命令全部不执行。 ## 推断的修复点 - niu 主进程应对 SIGPIPE 保持 SIG_IGN(与 bash 父 shell 一致),只有被 fork 出来的外部命令子进程恢复默认信号处理,或执行管道期间阻塞/一次性处理该信号。 环境: Niubash v1.3.3 / rubash 646237e9, Linux x86_64。
Activity
fix(coproc): give the child its fd-2 endpoint and startup signal poli…
fix(coproc): give the child its fd-2 endpoint and startup signal poli…
fix(executor): respawned fork-children die silently on EPIPE like GNU…