We can initialize the runtime sigqueue packages on first use.
We don't require an explicit initialization step. So, remove it.
Change-Id: I484e02dc2c67395fd5584f35ecda2e28b37168df
Reviewed-on: https://go-review.googlesource.com/c/go/+/226540
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
panic("os/signal: Notify using nil channel")
}
- watchSignalLoopOnce.Do(func() {
- if watchSignalLoop != nil {
- go watchSignalLoop()
- }
- })
-
handlers.Lock()
defer handlers.Unlock()
h.set(n)
if handlers.ref[n] == 0 {
enableSignal(n)
+
+ // The runtime requires that we enable a
+ // signal before starting the watcher.
+ watchSignalLoopOnce.Do(func() {
+ if watchSignalLoop != nil {
+ go watchSignalLoop()
+ }
+ })
}
handlers.ref[n]++
}
var sigtab = make(map[os.Signal]int)
-// In sig.s; jumps to runtime.
+// Defined by the runtime package.
func signal_disable(uint32)
func signal_enable(uint32)
func signal_ignore(uint32)
func signal_recv() string
func init() {
- signal_enable(0) // first call - initialize
-
watchSignalLoop = loop
}
}
func init() {
- signal_enable(0) // first call - initialize
-
watchSignalLoop = loop
}
//go:linkname signal_enable os/signal.signal_enable
func signal_enable(s uint32) {
if !sig.inuse {
- // The first call to signal_enable is for us
- // to use for initialization. It does not pass
- // signal information in m.
+ // This is the first call to signal_enable. Initialize.
sig.inuse = true // enable reception of signals; cannot disable
if GOOS == "darwin" {
sigNoteSetup(&sig.note)
- return
+ } else {
+ noteclear(&sig.note)
}
- noteclear(&sig.note)
- return
}
if s >= uint32(len(sig.wanted)*32) {
//go:linkname signal_enable os/signal.signal_enable
func signal_enable(s uint32) {
if !sig.inuse {
- // The first call to signal_enable is for us
- // to use for initialization. It does not pass
- // signal information in m.
+ // This is the first call to signal_enable. Initialize.
sig.inuse = true // enable reception of signals; cannot disable
noteclear(&sig.note)
- return
}
}