diff options
| author | Ian Lance Taylor <iant@golang.org> | 2016-09-27 22:24:51 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2016-09-28 13:12:47 +0000 |
| commit | eb268cb321edf6e2bbaa832acb2e61db6b081f98 (patch) | |
| tree | 7c2fd37a99424eec125732b6280f58d8af143072 /src/runtime/os_linux.go | |
| parent | 594cddd62598dcfc1fe6ee1c3e5978063f498dc1 (diff) | |
| download | go-eb268cb321edf6e2bbaa832acb2e61db6b081f98.tar.xz | |
runtime: minor simplifications to signal code
Change setsig, setsigstack, getsig, raise, raiseproc to take uint32 for
signal number parameter, as that is the type mostly used for signal
numbers. Same for dieFromSignal, sigInstallGoHandler, raisebadsignal.
Remove setsig restart parameter, as it is always either true or
irrelevant.
Don't check the handler in setsigstack, as the only caller does that
anyhow.
Don't bother to convert the handler from sigtramp to sighandler in
getsig, as it will never be called when the handler is sigtramp or
sighandler.
Don't check the return value from rt_sigaction in the GNU/Linux version
of setsigstack; no other setsigstack checks it, and it never fails.
Change-Id: I6bbd677e048a77eddf974dd3d017bc3c560fbd48
Reviewed-on: https://go-review.googlesource.com/29953
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 52b6b63868..ad9c1894dc 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -329,8 +329,8 @@ func sigprocmask(how int32, new, old *sigset) { //go:noescape func getrlimit(kind int32, limit unsafe.Pointer) int32 -func raise(sig int32) -func raiseproc(sig int32) +func raise(sig uint32) +func raiseproc(sig uint32) //go:noescape func sched_getaffinity(pid, len uintptr, buf *uintptr) int32 @@ -338,12 +338,9 @@ func osyield() //go:nosplit //go:nowritebarrierrec -func setsig(i int32, fn uintptr, restart bool) { +func setsig(i uint32, fn uintptr) { var sa sigactiont - sa.sa_flags = _SA_SIGINFO | _SA_ONSTACK | _SA_RESTORER - if restart { - sa.sa_flags |= _SA_RESTART - } + sa.sa_flags = _SA_SIGINFO | _SA_ONSTACK | _SA_RESTORER | _SA_RESTART sigfillset(&sa.sa_mask) // Although Linux manpage says "sa_restorer element is obsolete and // should not be used". x86_64 kernel requires it. Only use it on @@ -364,30 +361,23 @@ func setsig(i int32, fn uintptr, restart bool) { //go:nosplit //go:nowritebarrierrec -func setsigstack(i int32) { +func setsigstack(i uint32) { var sa sigactiont - if rt_sigaction(uintptr(i), nil, &sa, unsafe.Sizeof(sa.sa_mask)) != 0 { - throw("rt_sigaction failure") - } - if sa.sa_handler == 0 || sa.sa_handler == _SIG_DFL || sa.sa_handler == _SIG_IGN || sa.sa_flags&_SA_ONSTACK != 0 { + rt_sigaction(uintptr(i), nil, &sa, unsafe.Sizeof(sa.sa_mask)) + if sa.sa_flags&_SA_ONSTACK != 0 { return } sa.sa_flags |= _SA_ONSTACK - if rt_sigaction(uintptr(i), &sa, nil, unsafe.Sizeof(sa.sa_mask)) != 0 { - throw("rt_sigaction failure") - } + rt_sigaction(uintptr(i), &sa, nil, unsafe.Sizeof(sa.sa_mask)) } //go:nosplit //go:nowritebarrierrec -func getsig(i int32) uintptr { +func getsig(i uint32) uintptr { var sa sigactiont if rt_sigaction(uintptr(i), nil, &sa, unsafe.Sizeof(sa.sa_mask)) != 0 { throw("rt_sigaction read failure") } - if sa.sa_handler == funcPC(sigtramp) || sa.sa_handler == funcPC(cgoSigtramp) { - return funcPC(sighandler) - } return sa.sa_handler } |
