cmd/vet, os/signal: possible false-positive in sigchanyzer check when os.Signal channel is unused #45043
Comments
I am not sure I understand why this is safe yet. (So no informed cmd/vet opinion yet.) |
This came up in CL 217765 for #36976, where I copied a function from |
Code like It's not safe to write code like c := make(chan os.Signal)
signal.Notify(c, os.Interrupt)
// use c somewhere because the fact that the runtime uses a non-blocking send means that if the channel is unbuffered signals can be lost. In the case where the |
Roger that, thanks everyone for the discussion. I shall send a change tomorrow morning/afternoon, and get this fixed. |
Thanks for the pointer to |
@odeke-em , I would like to fix this in the |
All yours, thank you @AGMETEOR and welcome to the Go project, great to have you become a contributor! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I wrote a program that appears to be correct. It uses
signal.Notify
to catch SIGINT signals to prevent default handling but otherwise completely ignore them:Then ran
gotip vet .
on it.What did you expect to see?
No vet report, because as far as I can tell the os.Signal channel doesn't need to be buffered when it's completely unused.
What did you see instead?
CC @odeke-em, @ianlancetaylor, @timothy-king.
The text was updated successfully, but these errors were encountered: