From d11c58eedbee29b4912dd50508b36ad15ebb739e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 20 Sep 2022 12:24:07 -0700 Subject: 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 Run-TryBot: Ian Lance Taylor Reviewed-by: Bryan Mills Reviewed-by: Michael Pratt TryBot-Result: Gopher Robot --- src/runtime/os_linux.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/runtime/os_linux.go') 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 +} -- cgit v1.3