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

handle command interrupt #455

Merged
merged 3 commits into from
Dec 4, 2024
Merged

handle command interrupt #455

merged 3 commits into from
Dec 4, 2024

Conversation

nabuskey
Copy link
Collaborator

This PR makes idpbuilder handle interrupts correctly. Currently, idpbuilder doesn't handle signals well. For example, if you send ctrl+c while it's executing, it prints out a message saying Finished Creating IDP Successfully!. With this PR, it correctly says that the command execution was interrupted. It still prints command usages at the end but we can address that in another PR.

err = <-managerExit
close(managerExit)
return err
interrupted := make(chan os.Signal, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way we could move this "out" since its really a global cancellation, not simply cancelling this subroutine. I'm used to this getting set up along with other intialization, usually in the main() method. We should be able to cancel a context there which cascades down in to cancelling this context.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah good idea. Will move it up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@greghaynes done.

Copy link
Contributor

@cmoulliard cmoulliard left a comment

Choose a reason for hiding this comment

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

Should we also add SIGINT to tell to the program to print interrupt and then exit ?

See: https://gobyexample.com/signals

@nabuskey
Copy link
Collaborator Author

Should we also add SIGINT to tell to the program to print interrupt and then exit ?

See: https://gobyexample.com/signals

My understanding is os.Interrupt is essentially SIGINT because that's one of the few signals guaranteed to be available on all systems. So we should be good here.

Signed-off-by: Manabu McCloskey <[email protected]>
Signed-off-by: Manabu McCloskey <[email protected]>
Signed-off-by: Manabu McCloskey <[email protected]>
@nabuskey nabuskey merged commit 406cc03 into cnoe-io:main Dec 4, 2024
5 checks passed
@nabuskey nabuskey deleted the trap-c branch December 4, 2024 23:10
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.

3 participants