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: Catch OS agnostic interrupt signal #755

Merged
merged 1 commit into from
Jan 11, 2022
Merged

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Jan 6, 2022

While debugging #733 Windows users have reported that CPU profile never gets written in their environment.

This is because CPU profile only gets written upon (graceful) shutdown which we perform by catching particular interrupt/termination signals. Prior to this patch however we were only catching Unix-native signals, which Windows never sends, resulting in dirty shutdowns and never giving the opportunity for a CPU profile to be written to disk.

See also: https://pkg.go.dev/os/signal#hdr-Windows and https://stackoverflow.com/a/35683558

@radeksimko radeksimko added the bug Something isn't working label Jan 6, 2022
As per docs (https://pkg.go.dev/os/signal#hdr-Windows) os.Interrupt
is an OS-agnostic "signal" as opposed to syscall.SIGINT which is Unix-only.

This should enable us to catch interrupts on Windows too,
therefore do more graceful shutdowns and also write CPU profile.
@radeksimko radeksimko requested a review from a team January 6, 2022 14:00
@radeksimko radeksimko marked this pull request as ready for review January 6, 2022 14:00
Copy link
Member

@dbanck dbanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I found that it's still possible to get a 0kb file when writing CPU profiles. I assume that sometimes VSCode will relaunch the process, overwriting the "valid" profile with an empty 0kb one. The safest way to avoid this is to use a timestamp in the filename.

@radeksimko radeksimko merged commit 58e0e79 into main Jan 11, 2022
@radeksimko radeksimko deleted the b-catch-os-interrupt branch January 11, 2022 11:21
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants