runtime: signal.Ignore(syscall.SIGPIPE) does not work as documented #32386
Labels
FrozenDueToAge
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Based on the documentation, calling
signal.Ignore(syscall.SIGPIPE)
should causeSIGPIPE
to be ignored. But that is not the case.What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The following program calls
signal.Ignore()
to try to ignoreSIGPIPE
:But when the program is run with stdout piped into a process that terminates quickly, the resulting
SIGPIPE
signal causes it to die:What did you expect to see?
I expected the program not be killed by
SIGPIPE
, and to report thatPrintf
failed withEPIPE
. This expectation is based on the documentation forsignal.Ignore()
(especially the second sentence):My expectation is also consistent with the description of how
SIGPIPE
is handled](https://golang.org/pkg/os/signal/#hdr-SIGPIPE).What did you see instead?
The program was killed by
SIGPIPE
.Discussion
The above commands were run using
bash
. I also tried underdash
, with the same results.If the original program is built in a separate step and then the binary is run, it doesn't print "signal: broken pipe" but it still dies after only one second and without printing the subsequent information to stderr:
Contrast that with running the same program using
go run
, as above:Note that it also completes in just over a second, but this time with the
signal: broken pipe
message.Note that it is possible to cause
SIGPIPE
to really be ignored by callingBut if you follow that call with another call to
signal.Ignore(syscall.SIGPIPE)
, the signal again fails to be ignored.The text was updated successfully, but these errors were encountered: