Skip to content

handle command interrupt#455

Merged
nabuskey merged 3 commits intocnoe-io:mainfrom
nabuskey:trap-c
Dec 4, 2024
Merged

handle command interrupt#455
nabuskey merged 3 commits intocnoe-io:mainfrom
nabuskey:trap-c

Conversation

@nabuskey
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <manabu.mccloskey@gmail.com>
Signed-off-by: Manabu McCloskey <manabu.mccloskey@gmail.com>
Signed-off-by: Manabu McCloskey <manabu.mccloskey@gmail.com>
@nabuskey nabuskey merged commit 406cc03 into cnoe-io:main Dec 4, 2024
@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