Skip to content

Conversation

@haoqixu
Copy link
Contributor

@haoqixu haoqixu commented Mar 1, 2023

Use buffered os.Signal channel as argument to signal.Notify to ensure that we do not drop a signal notification.

@haoel
Copy link
Contributor

haoel commented Mar 1, 2023

Thanks for this PR, cloud you please let me understand the situation which could drop the signal notification?

@haoqixu
Copy link
Contributor Author

haoqixu commented Mar 1, 2023

https://pkg.go.dev/os/signal#Notify:

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.

Any signal which arrives after signal.Notify but before <-done will get discarded. It is just technically possible and not a big problem here.

@haoel
Copy link
Contributor

haoel commented Mar 1, 2023

Thanks for this explanation

@haoel haoel added this pull request to the merge queue Mar 1, 2023
Merged via the queue into megaease:main with commit 504b25d Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants