Closed CyprienRicque closed 2 years ago
Pretty sure this is not an actual bug. As per the POSIX specification, I believe this is expected behavior:
A SIGPIPE signal is raised if a thread sends on a broken stream (one that is no longer connected). ... The SIGPIPE signal shall be sent to a thread that attempts to send data on a socket that is no longer able to send. In addition, the send operation fails with the error [EPIPE]. _http://pubs.opengroup.org/onlinepubs/007904875/functions/xsh_chap02_10.html_
Also, translated from the 1st table in another piece of reference documentation:
Signal: SIGPIPE Default Action: Abnormal termination of the process. Description: Write on a pipe with no one to read it. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
Without digging into the code at all, I'd guess that exiting the shell immediately releases the tty, thereby closing STDOUT before ls
tries to write to it, which would very correctly result in a SIGPIPE according to specification.
For more info on when write() returns an EPIPE/SIGPIPE, please refer to the reference documentation here: https://pubs.opengroup.org/onlinepubs/009695399/functions/write.html
I'm not sure what is expected in this ticket. Can you clarify?
pipes to and from builtins are kind of broken. see https://bugs.astron.com/view.php?id=153
Closing in preference of tracking this in the more general ticket linked above.
ls | exit ; ls : sigpipe but ls | exit : don't sigpipe