Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use buffered os.Signal channel as argument to signal.Notify #295

Merged
merged 1 commit into from
Mar 1, 2023

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.

None yet

2 participants