aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/signal_unix.go
diff options
context:
space:
mode:
authorElias Naur <mail@eliasnaur.com>2019-07-31 14:33:57 +0200
committerElias Naur <mail@eliasnaur.com>2019-08-29 12:51:31 +0000
commitd56a86e01f2e771a4706f0a5cfbe2d87cd888f05 (patch)
tree110c8115facb5e2161f13aa6df7b7d33de3ac531 /src/runtime/signal_unix.go
parent5cf5a6fc5eca5e05ab7cd189a19196e73c5408c4 (diff)
downloadgo-d56a86e01f2e771a4706f0a5cfbe2d87cd888f05.tar.gz
go-d56a86e01f2e771a4706f0a5cfbe2d87cd888f05.zip
runtime: don't forward SIGPIPE on macOS
macOS and iOS deliver SIGPIPE signals to the main thread and not the thread that raised it by writing to a closed socket or pipe. SIGPIPE signals can be suppressed for sockets with the SO_NOSIGPIPE option, but there is no similar option for pipes. We have no other choice but to never forward SIGPIPE on macOS. Fixes #33384 Change-Id: Ice3de75b121f00006ee11c26d560e619536460be Reviewed-on: https://go-review.googlesource.com/c/go/+/188297 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/signal_unix.go')
-rw-r--r--src/runtime/signal_unix.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
index ad51dc1800..436c18c126 100644
--- a/src/runtime/signal_unix.go
+++ b/src/runtime/signal_unix.go
@@ -636,6 +636,13 @@ func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
return true
}
+ // This function and its caller sigtrampgo assumes SIGPIPE is delivered on the
+ // originating thread. This property does not hold on macOS (golang.org/issue/33384),
+ // so we have no choice but to ignore SIGPIPE.
+ if GOOS == "darwin" && sig == _SIGPIPE {
+ return true
+ }
+
// If there is no handler to forward to, no need to forward.
if fwdFn == _SIG_DFL {
return false