]> Cypherpunks repositories - gostls13.git/commit
os/signal: lazily start signal watch loop only on Notify
authorEmmanuel T Odeke <emmanuel@orijtech.com>
Mon, 11 Mar 2019 17:52:00 +0000 (10:52 -0700)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Wed, 2 Oct 2019 03:52:59 +0000 (03:52 +0000)
commite79b57d6c40a25393b2d831b244b19548e23b8a4
tree4f8d837a71a1a4be212ce63c83c1d2117a80a27f
parenta1b0af9904e3cc1cd169da7f0e5ad81420cd728e
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>
src/os/signal/signal.go
src/os/signal/signal_plan9.go
src/os/signal/signal_unix.go
src/runtime/testdata/testprogcgo/numgoroutine.go
test/fixedbugs/issue21576.go [new file with mode: 0644]