-
Notifications
You must be signed in to change notification settings - Fork 28
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
centralize registration of exit handlers #230
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Luca Stocchi <[email protected]>
Signed-off-by: Luca Stocchi <[email protected]>
// This method is useful when a caller wishes to execute a func before a shutdown. | ||
func RegisterExitHandler(handler func()) { | ||
exitHandlers = append(exitHandlers, handler) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of a global variable means RegisterExitHandler
should not be called from multiple go routines simultaneously. The next commit will call it from a go routine which is not the main one, it's safer to add a mutex to protect accesses to exitHandlers
.
this PR centralizes the registration of exit handlers so that we can register an exit handler from anywhere and it will be invoked before terminating vfkit.
The PR also registers an exit handler to remove the ignition socket.
It resolves #229