diff options
| author | Ian Lance Taylor <iant@golang.org> | 2018-03-06 20:47:38 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2018-03-07 23:30:02 +0000 |
| commit | c2f28de732749425ea29b5efa982c407964f8560 (patch) | |
| tree | ceed9e1e77033e10ef85d650323740dacb021e1b /src/runtime/os_linux.go | |
| parent | d8c9ef9e5cb6d485d9e15a48884ffb1162c48fb3 (diff) | |
| download | go-c2f28de732749425ea29b5efa982c407964f8560.tar.xz | |
runtime: change from rt_sigaction to sigaction
This normalizes the Linux code to act like other targets. The size
argument to the rt_sigaction system call is pushed to a single
function, sysSigaction.
This is intended as a simplification step for CL 93875 for #14327.
Change-Id: I594788e235f0da20e16e8a028e27ac8c883907c4
Reviewed-on: https://go-review.googlesource.com/99077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index d8c1592a1d..779f7403ec 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -378,28 +378,26 @@ func setsig(i uint32, fn uintptr) { } } sa.sa_handler = fn - rt_sigaction(uintptr(i), &sa, nil, unsafe.Sizeof(sa.sa_mask)) + sigaction(i, &sa, nil) } //go:nosplit //go:nowritebarrierrec func setsigstack(i uint32) { var sa sigactiont - rt_sigaction(uintptr(i), nil, &sa, unsafe.Sizeof(sa.sa_mask)) + sigaction(i, nil, &sa) if sa.sa_flags&_SA_ONSTACK != 0 { return } sa.sa_flags |= _SA_ONSTACK - rt_sigaction(uintptr(i), &sa, nil, unsafe.Sizeof(sa.sa_mask)) + sigaction(i, &sa, nil) } //go:nosplit //go:nowritebarrierrec 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") - } + sigaction(i, nil, &sa) return sa.sa_handler } @@ -411,3 +409,15 @@ func setSignalstackSP(s *stackt, sp uintptr) { func (c *sigctxt) fixsigcode(sig uint32) { } + +// sysSigaction calls the rt_sigaction system call. +//go:nosplit +func sysSigaction(sig uint32, new, old *sigactiont) { + if rt_sigaction(uintptr(sig), new, old, unsafe.Sizeof(sigactiont{}.sa_mask)) != 0 { + throw("sigaction failed") + } +} + +// rt_sigaction is implemented in assembly. +//go:noescape +func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32 |
