Helo, On 2019-02-15 8:20 a.m., Eric Blake wrote: > On 2/15/19 8:43 AM, 積丹尼 Dan Jacobson wrote: >> sort: write failed: 'standard output': Broken pipe >> sort: write error [...] > Perhaps coreutils should teach 'env' a command-line option to forcefully > reset SIGPIPE back to default behavior [...] If we > did that, then even if your sh is started with SIGPIPE ignored (so that > the shell itself can't restore default behavior), you could do this > theoretical invocation: > > $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l > 5 That is a nice idea, I could've used it myself couple of times. Attached a suggested patch. If this seems like a good direction, I'll complete it with NEWS/docs/etc. Usage is: env --default-signal=PIPE env -P ##shortcut to reset SIGPIPE env --default-signal=PIPE,INT,FOO This also works nicely with the recent 'env -S' option, so a script like so can always start with default SIGPIPE handler: #!/usr/bin/env -S -P sh seq inf | head -n1 comments welcomed, - assaf