diff options
| author | Ian Lance Taylor <iant@golang.org> | 2022-09-15 11:33:58 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-17 01:41:08 +0000 |
| commit | 7c87012f041948af55d323fc5447230c930e79aa (patch) | |
| tree | ca7338bb06edf5e9f029c2e134238d187be1befd /src/runtime/os_linux.go | |
| parent | a9ca741d311772efb828c4b4f45e737783a89ca3 (diff) | |
| download | go-7c87012f041948af55d323fc5447230c930e79aa.tar.xz | |
runtime: treat SI_TKILL like SI_USER on Linux
On Linux a signal sent using tgkill will have si_code == SI_TKILL,
not SI_USER. Treat the two cases the same. Add a Linux-specific test.
Change the test to use the C pause function rather than sleeping
for a second, as that achieves the same effect.
Change-Id: I2a36646aecabcab9ec42ed9a048b07c2ff0a3987
Reviewed-on: https://go-review.googlesource.com/c/go/+/431255
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index 3ae665c83d..e84f065e24 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -886,3 +886,15 @@ func runPerThreadSyscall() { gp.m.needPerThreadSyscall.Store(0) } + +const ( + _SI_USER = 0 + _SI_TKILL = -6 +) + +// sigFromUser reports whether the signal was sent because of a call +// to kill or tgkill. +func (c *sigctxt) sigFromUser() bool { + code := int32(c.sigcode()) + return code == _SI_USER || code == _SI_TKILL +} |
