diff options
| author | Elias Naur <elias.naur@gmail.com> | 2016-12-01 09:31:08 +0000 |
|---|---|---|
| committer | Elias Naur <elias.naur@gmail.com> | 2016-12-01 11:23:17 +0000 |
| commit | 0b2daa56504e0f2ff6f724eb5bb71caed0011006 (patch) | |
| tree | d3db4d838a413d96221850565a41da06658be051 /src | |
| parent | 16c33992e0848209d0254bdb5c8f6c7b7ceb5c60 (diff) | |
| download | go-0b2daa56504e0f2ff6f724eb5bb71caed0011006.tar.xz | |
Revert "runtime: handle SIGPIPE in c-archive and c-shared programs"
This reverts commit d24b57a6a1a3530e590b7c0a72dc78043e198630.
Reason for revert: Further complications arised (issue 18100). We'll try again in Go 1.9.
Change-Id: I5ca93d2643a4be877dd9c2d8df3359718440f02f
Reviewed-on: https://go-review.googlesource.com/33770
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/os/signal/doc.go | 9 | ||||
| -rw-r--r-- | src/runtime/signal_unix.go | 14 |
2 files changed, 8 insertions, 15 deletions
diff --git a/src/os/signal/doc.go b/src/os/signal/doc.go index 16f49c7ab8..73b01a2764 100644 --- a/src/os/signal/doc.go +++ b/src/os/signal/doc.go @@ -181,11 +181,10 @@ If the Go runtime sees an existing signal handler for the SIGCANCEL or SIGSETXID signals (which are used only on GNU/Linux), it will turn on the SA_ONSTACK flag and otherwise keep the signal handler. -For the synchronous signals and SIGPIPE, the Go runtime will install a -signal handler. It will save any existing signal handler. If a -synchronous signal arrives while executing non-Go code, the Go runtime -will invoke the existing signal handler instead of the Go signal -handler. +For the synchronous signals, the Go runtime will install a signal +handler. It will save any existing signal handler. If a synchronous +signal arrives while executing non-Go code, the Go runtime will invoke +the existing signal handler instead of the Go signal handler. Go code built with -buildmode=c-archive or -buildmode=c-shared will not install any other signal handlers by default. If there is an diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 78381e58d7..19173ac211 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -111,8 +111,8 @@ func sigInstallGoHandler(sig uint32) bool { } // When built using c-archive or c-shared, only install signal - // handlers for synchronous signals and SIGPIPE. - if (isarchive || islibrary) && t.flags&_SigPanic == 0 && sig != _SIGPIPE { + // handlers for synchronous signals. + if (isarchive || islibrary) && t.flags&_SigPanic == 0 { return false } @@ -497,15 +497,9 @@ func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool { return true } + // Only forward synchronous signals. c := &sigctxt{info, ctx} - // Only forward signals from the kernel. - // On Linux and Darwin there is no way to distinguish a SIGPIPE raised by a write - // to a closed socket or pipe from a SIGPIPE raised by kill or pthread_kill - // so we'll treat every SIGPIPE as kernel-generated. - userSig := c.sigcode() == _SI_USER && - (sig != _SIGPIPE || GOOS != "linux" && GOOS != "android" && GOOS != "darwin") - // Only forward synchronous signals and SIGPIPE. - if userSig || flags&_SigPanic == 0 && sig != _SIGPIPE { + if c.sigcode() == _SI_USER || flags&_SigPanic == 0 { return false } // Determine if the signal occurred inside Go code. We test that: |
