On 2021-06-29 14:11:45 +0100, Stephane Chazelas via austin-group-l at The Open 
Group wrote:
> 2021-06-29 09:49:40 +0100, Geoff Clare via austin-group-l at The Open Group:
> [...]
> > > If in general, then forget it - the users would lynch you (you'd probably
> > > suicide first) if you successfully caused that to happen.
> > 
> > No they wouldn't.  The only reason to set SIGPIPE to be ignored is
> > because you want EPIPE error conditions to be diagnosed instead of
> > causing the process to terminate.
> [...]
> 
> Should SIGPIPE cause the *shell* process to terminate by the way
> when a builtin tries to write to a broken pipe (the reverse
> problem of the one being discussed here)?

Yes, but this is not specific to builtins (assuming the command fails
on a broken pipe).

I would expect

(
  trap '' PIPE
  set -e
  while true; do pwd 2> /dev/null; done
)

be something similar to "yes", but with the working directory on stdout
instead of "yes".

> (
>   sleep 1
>   set +o errexit -o xtrace
>   pwd
>   pwd
> ) | :
> 
> Calls pwd only once with most shell implementations (all those
> where pwd is builtin).
> 
> Is that allowed?

Since POSIX doesn't require to ignore or trap SIGPIPE before executing
a builtin, I would say that it is the expected behavior with builtins.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to