diff options
author | David Crawshaw <crawshaw@golang.org> | 2015-04-24 12:47:46 -0400 |
---|---|---|
committer | David Crawshaw <crawshaw@golang.org> | 2015-04-26 13:46:13 +0000 |
commit | a5b693b431d0612b97a8978fdfa7d12310d95b6f (patch) | |
tree | 0ac5d1ef90817868f2129b6b43394bd23de6cb1c /src/runtime/signal_darwin.go | |
parent | c20ff36fe2379d313602496ff3c269af2a8a1839 (diff) | |
download | go-a5b693b431d0612b97a8978fdfa7d12310d95b6f.tar.gz go-a5b693b431d0612b97a8978fdfa7d12310d95b6f.zip |
runtime: signal forwarding for darwin/amd64
Follows the linux signal forwarding semantics from
http://golang.org/cl/8712, sharing the implementation of sigfwdgo.
Forwarding for 386, arm, and arm64 will follow.
Change-Id: I6bf30d563d19da39b6aec6900c7fe12d82ed4f62
Reviewed-on: https://go-review.googlesource.com/9302
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/signal_darwin.go')
-rw-r--r-- | src/runtime/signal_darwin.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/runtime/signal_darwin.go b/src/runtime/signal_darwin.go index 122648bc33..32ecce0d7d 100644 --- a/src/runtime/signal_darwin.go +++ b/src/runtime/signal_darwin.go @@ -4,6 +4,8 @@ package runtime +import "unsafe" + type sigTabT struct { flags int32 name string @@ -43,3 +45,27 @@ var sigtable = [...]sigTabT{ /* 30 */ {_SigNotify, "SIGUSR1: user-defined signal 1"}, /* 31 */ {_SigNotify, "SIGUSR2: user-defined signal 2"}, } + +//go:noescape +func sigfwd(fn uintptr, sig uint32, info *siginfo, ctx unsafe.Pointer) + +//go:noescape +func sigreturn(ctx unsafe.Pointer, infostyle uint32) + +//go:nosplit +func sigtrampgo(fn uintptr, infostyle, sig uint32, info *siginfo, ctx unsafe.Pointer) { + if sigfwdgo(sig, info, ctx) { + sigreturn(ctx, infostyle) + return + } + g := getg() + if g == nil { + badsignal(uintptr(sig)) + sigreturn(ctx, infostyle) + return + } + setg(g.m.gsignal) + sighandler(sig, info, ctx, g) + setg(g) + sigreturn(ctx, infostyle) +} |