aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sigqueue.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-01-07 10:19:55 -0500
committerRuss Cox <rsc@golang.org>2016-01-08 15:34:03 +0000
commit81adfa508a81e24b8257571dd717845647607cbd (patch)
tree6da40730c40d4f3fd32e84d43b7a988d216761bc /src/runtime/sigqueue.go
parent331a6055ab8785e77bd1331355d209bd7da2ae26 (diff)
downloadgo-81adfa508a81e24b8257571dd717845647607cbd.tar.xz
runtime: allow signal.Ignore of user-generated throwing signals
Today, signal.Ignore(syscall.SIGTRAP) does nothing while signal.Notify(make(chan os.Signal), syscall.SIGTRAP) correctly discards user-generated SIGTRAPs. The same applies to any signal that we throw on. Make signal.Ignore work for these signals. Fixes #12906. Change-Id: Iba244813051e0ce23fa32fbad3e3fa596a941094 Reviewed-on: https://go-review.googlesource.com/18348 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/sigqueue.go')
-rw-r--r--src/runtime/sigqueue.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/runtime/sigqueue.go b/src/runtime/sigqueue.go
index 8c9951ae1d..84616ebceb 100644
--- a/src/runtime/sigqueue.go
+++ b/src/runtime/sigqueue.go
@@ -34,12 +34,13 @@ import (
)
var sig struct {
- note note
- mask [(_NSIG + 31) / 32]uint32
- wanted [(_NSIG + 31) / 32]uint32
- recv [(_NSIG + 31) / 32]uint32
- state uint32
- inuse bool
+ note note
+ mask [(_NSIG + 31) / 32]uint32
+ wanted [(_NSIG + 31) / 32]uint32
+ ignored [(_NSIG + 31) / 32]uint32
+ recv [(_NSIG + 31) / 32]uint32
+ state uint32
+ inuse bool
}
const (
@@ -146,6 +147,7 @@ func signal_enable(s uint32) {
return
}
sig.wanted[s/32] |= 1 << (s & 31)
+ sig.ignored[s/32] &^= 1 << (s & 31)
sigenable(s)
}
@@ -166,9 +168,15 @@ func signal_ignore(s uint32) {
return
}
sig.wanted[s/32] &^= 1 << (s & 31)
+ sig.ignored[s/32] |= 1 << (s & 31)
sigignore(s)
}
+// Checked by signal handlers.
+func signal_ignored(s uint32) bool {
+ return sig.ignored[s/32]&(1<<(s&31)) != 0
+}
+
// This runs on a foreign stack, without an m or a g. No stack split.
//go:nosplit
//go:norace