Skip to content

Commit

Permalink
runtime: don't always block all signals on OpenBSD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Elias Naur authored and ianlancetaylor committed May 23, 2015
1 parent eeb64b7 commit 8017ace
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/runtime/os1_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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)
}

Expand Down

0 comments on commit 8017ace

Please sign in to comment.