Skip to content

Commit 10240b9

Browse files
Cuong Manh Lecuonglm
Cuong Manh Le
authored andcommitted
cmd/go: fix unbuffered channel passed to signal.Notify
Unbuffered channels passed into signal.Notify can be lost as the docs for signal.Notify caution with: Package signal will not block sending to c: the caller must ensure that c has sufficient buffer space to keep up with the expected signal rate. For a channel used for notification of just one signal value, a buffer of size 1 is sufficient. Found by a static analyzer from Orijtech, Inc. called "sigchanyzer", but it'll be donated to the Go project soon. Updates #9399. Change-Id: Ia0690e447582da028694ed65ace7b97961997b84 Reviewed-on: https://go-review.googlesource.com/c/go/+/274332 Trust: Cuong Manh Le <[email protected]> Trust: Emmanuel Odeke <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent c32140f commit 10240b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/go/internal/base/signal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var Interrupted = make(chan struct{})
1515

1616
// processSignals setups signal handler.
1717
func processSignals() {
18-
sig := make(chan os.Signal)
18+
sig := make(chan os.Signal, 1)
1919
signal.Notify(sig, signalsToIgnore...)
2020
go func() {
2121
<-sig

0 commit comments

Comments
 (0)