aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_linux.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-09-20 12:24:07 -0700
committerGopher Robot <gobot@golang.org>2022-09-21 01:56:24 +0000
commitd11c58eedbee29b4912dd50508b36ad15ebb739e (patch)
tree9306af01cc8b15d02076420e86dc8db063712526 /src/runtime/os_linux.go
parentfec83c8a7d1a3bb5f63366acd55f83ed8782bff0 (diff)
downloadgo-d11c58eedbee29b4912dd50508b36ad15ebb739e.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. This is a roll forward of CL 431255 which was rolled back in CL 431715. This new version skips flaky tests on more systems, and marks a new method nosplit. Change-Id: Ibf2d3e6fc43d63d0a71afa8fcca6a11fda03f291 Reviewed-on: https://go-review.googlesource.com/c/go/+/432136 Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/os_linux.go')
-rw-r--r--src/runtime/os_linux.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index 3ae665c83d..53629ec90b 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -886,3 +886,17 @@ 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.
+//
+//go:nosplit
+func (c *sigctxt) sigFromUser() bool {
+ code := int32(c.sigcode())
+ return code == _SI_USER || code == _SI_TKILL
+}