mirror of
https://github.com/golang/go.git
synced 2025-11-11 06:01:06 +00:00
os/signal: lazily start signal watch loop only on Notify
By lazily starting the signal watch loop only on Notify, we are able to have deadlock detection even when "os/signal" is imported. Thanks to Ian Lance Taylor for the solution and discussion. With this change in, fix a runtime gorountine count test that assumed that os/signal.init would unconditionally start the signal watching goroutine, but alas no more. Fixes #21576. Change-Id: I6eecf82a887f59f2ec8897f1bcd67ca311ca42ff Reviewed-on: https://go-review.googlesource.com/c/go/+/101036 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
a1b0af9904
commit
e79b57d6c4
5 changed files with 79 additions and 9 deletions
|
|
@ -26,7 +26,8 @@ func loop() {
|
|||
|
||||
func init() {
|
||||
signal_enable(0) // first call - initialize
|
||||
go loop()
|
||||
|
||||
watchSignalLoop = loop
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue