runtime: if os/signal is not in use, crash on
most signals, so that ordinary programs
can be killed, for example.
Fixes #434.
R=dsymonds1
CC=golang-dev, hoisie
https://golang.org/cl/180064
diff --git a/src/pkg/runtime/sigqueue.cgo b/src/pkg/runtime/sigqueue.cgo
index 059d3ed..c3751c5d 100644
--- a/src/pkg/runtime/sigqueue.cgo
+++ b/src/pkg/runtime/sigqueue.cgo
@@ -43,6 +43,7 @@
static struct {
Note;
uint32 mask;
+ bool inuse;
} sig;
void
@@ -52,24 +53,27 @@
}
// Called from sighandler to send a signal back out of the signal handling thread.
-void
+bool
sigsend(int32 s)
{
uint32 bit, mask;
+ if(!sig.inuse)
+ return false;
bit = 1 << s;
for(;;) {
mask = sig.mask;
if(mask & bit)
- return; // signal already in queue
+ break; // signal already in queue
if(cas(&sig.mask, mask, mask|bit)) {
// Added to queue.
// Only send a wakeup for the first signal in each round.
if(mask == 0)
notewakeup(&sig);
- return;
+ break;
}
}
+ return true;
}
// Called to receive a bitmask of queued signals.
@@ -88,3 +92,7 @@
func Signame(sig int32) (name String) {
name = signame(sig);
}
+
+func Siginit() {
+ sig.inuse = true; // enable reception of signals; cannot disable
+}