mirror of
https://github.com/golang/go
synced 2024-11-18 06:34:53 -07:00
runtime: don't always block all signals on OpenBSD
Implement the changes from CL 10173 on OpenBSD. Change-Id: I2db1cd8141fd392a34753a1b8113e2e0401173b9 Reviewed-on: https://go-review.googlesource.com/10342 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
eeb64b7fef
commit
8017ace496
@ -149,6 +149,11 @@ func mpreinit(mp *m) {
|
||||
}
|
||||
|
||||
func msigsave(mp *m) {
|
||||
smask := (*uint32)(unsafe.Pointer(&mp.sigmask))
|
||||
if unsafe.Sizeof(*smask) > unsafe.Sizeof(mp.sigmask) {
|
||||
throw("insufficient storage for signal mask")
|
||||
}
|
||||
*smask = sigprocmask(_SIG_BLOCK, 0)
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
@ -161,11 +166,22 @@ func minit() {
|
||||
|
||||
// Initialize signal handling
|
||||
signalstack((*byte)(unsafe.Pointer(_g_.m.gsignal.stack.lo)), 32*1024)
|
||||
sigprocmask(_SIG_SETMASK, sigset_none)
|
||||
|
||||
// restore signal mask from m.sigmask and unblock essential signals
|
||||
nmask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask))
|
||||
for i := range sigtable {
|
||||
if sigtable[i].flags&_SigUnblock != 0 {
|
||||
nmask &^= 1 << (uint32(i) - 1)
|
||||
}
|
||||
}
|
||||
sigprocmask(_SIG_SETMASK, nmask)
|
||||
}
|
||||
|
||||
// Called from dropm to undo the effect of an minit.
|
||||
func unminit() {
|
||||
_g_ := getg()
|
||||
smask := *(*uint32)(unsafe.Pointer(&_g_.m.sigmask))
|
||||
sigprocmask(_SIG_SETMASK, smask)
|
||||
signalstack(nil, 0)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user