From 334291d1f629fb027bfcd7bff6d30e01dd9bf4c5 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 3 Oct 2019 10:19:38 -0400 Subject: runtime: M-targeted signals for Linux We'll add a test once all of the POSIX platforms are done. For #10958, #24543. Change-Id: If7e3f14e8391791364877629bf415d9f8e788b0a Reviewed-on: https://go-review.googlesource.com/c/go/+/201401 Run-TryBot: Austin Clements Reviewed-by: Cherry Zhang --- src/runtime/os_linux.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/runtime/os_linux.go') diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index b1ddf53dd1..20b947f250 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -332,7 +332,9 @@ func gettid() uint32 func minit() { minitSignals() - // for debuggers, in case cgo created the thread + // Cgo-created threads and the bootstrap m are missing a + // procid. We need this for asynchronous preemption and its + // useful in debuggers. getg().m.procid = uint64(gettid()) } @@ -454,3 +456,11 @@ func sysSigaction(sig uint32, new, old *sigactiont) { // rt_sigaction is implemented in assembly. //go:noescape func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32 + +func getpid() int +func tgkill(tgid, tid, sig int) + +// signalM sends a signal to mp. +func signalM(mp *m, sig int) { + tgkill(getpid(), int(mp.procid), sig) +} -- cgit v1.3