diff options
author | Austin Clements <austin@google.com> | 2019-10-03 10:19:38 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2019-10-26 02:52:25 +0000 |
commit | 334291d1f629fb027bfcd7bff6d30e01dd9bf4c5 (patch) | |
tree | ca39d1a053e14b2b68208133183019e7ffa209e0 /src/runtime/os_linux.go | |
parent | 3706cd85d37ec554821393eb49cb3c88edf9308a (diff) | |
download | go-334291d1f629fb027bfcd7bff6d30e01dd9bf4c5.tar.gz go-334291d1f629fb027bfcd7bff6d30e01dd9bf4c5.zip |
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 <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/os_linux.go')
-rw-r--r-- | src/runtime/os_linux.go | 12 |
1 files changed, 11 insertions, 1 deletions
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) +} |