Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection
-Wformat -Werror=format-security -fcf-protection -Wall
uname output: Linux user 6.8.0-79-generic #79-Ubuntu SMP PREEMPT_DYNAMIC Tue
Aug 12 14:42:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.2
Patch Level: 21
Release Status: release
Description:
When I redirect the output of a command that sleeps into a process
substitution with a process that finishes immediately (like "echo" or
a process that doesn't exist), after the first sleep, Bash will crash
with exit code 141.
It also works with today's "bash-master", which reports its version
as 5.3.3(1)-release.
Repeat-By:
Running this command will show the issue:
for i in 1 2 3 4 5; do sleep 1; echo $i; done > >(echo)
After one second, rather than interrupting the command and continuing
normally, Bash will crash entirely with a "Broken pipe" error. On a GUI
desktop, this is apparent by the terminal window closing suddenly. On
a non-GUI desktop, this will kick the user out of the current session.
This can be mitigated by spawning another shell to run the command,
such as "bash -c '<the command>'".
Replacing the "echo" in ">(echo)" with anything that exits early, for
example a non-existent command, will behave similarly.
Another, simpler command that exhibits the same behavior:
(sleep 1; echo) > >(echo)
Curiously, this crashes my GUI terminal window, but does not kick me
out of my non-GUI terminal session. The 141 exit code is observable
nevertheless.