| // Copyright 2012 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // +build darwin dragonfly freebsd linux netbsd openbsd solaris |
| //go:linkname os_sigpipe os.sigpipe |
| // Determines if the signal should be handled by Go and if not, forwards the |
| // signal to the handler that was installed before Go's. Returns whether the |
| func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool { |
| if sig >= uint32(len(sigtable)) { |
| flags := sigtable[sig].flags |
| // If there is no handler to forward to, no need to forward. |
| // Only forward synchronous signals. |
| if c.sigcode() == _SI_USER || flags&_SigPanic == 0 { |
| // Determine if the signal occurred inside Go code. We test that: |
| // (1) we were in a goroutine (i.e., m.curg != nil), and |
| // (2) we weren't in CGO (i.e., m.curg.syscallsp == 0). |
| if g != nil && g.m != nil && g.m.curg != nil && g.m.curg.syscallsp == 0 { |
| // Signal not handled by Go, forward it. |
| sigfwd(fwdFn, sig, info, ctx) |