-
Notifications
You must be signed in to change notification settings - Fork 61
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
batches: handle interrupt signals in batch preview
#793
Conversation
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.
Thank you!
wondering how you found that 😬 |
@@ -533,7 +534,7 @@ func checkExecutable(cmd string, args ...string) error { | |||
func contextCancelOnInterrupt(parent context.Context) (context.Context, func()) { |
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.
maybe that name is not 100% accurate anymore.
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.
Makes sense to me.
Did a bit more digging into this and the fix doesn't quite work as expected. Sending I updated the goroutine that handles the signal to go func() {
select {
case <-c:
ctxCancel()
os.Exit(0)
case <-ctx.Done():
}
}() However, this means we always exit automatically after canceling the cotext and I'm not sure this is the right way to go about this. Does anyone have any insight as to the best approach to this? |
This is essentially a copy-paste implementation of the ideas presented in this comment here: golang/go#20280 (comment) It fixes #775 and helps with the issue described in #793 (comment). Not sure if it has unintended side-effects.
I got kinda nerd-sniped reading through this... My first thought was: "isn't there a way to abort an It seems to do what it should do, but not sure about unintended side-effects etc. Just wanted to possibly add something to conversation 🙂 |
(Also, have to mention this: the reading stops when you hit |
Thanks @mrnugget . Testing it out now and reading the attached issue. |
Closing this for now. I'll work with Thorsten on his fix for this problem. |
This is essentially a copy-paste implementation of the ideas presented in this comment here: golang/go#20280 (comment) It fixes #775 and helps with the issue described in #793 (comment). Not sure if it has unintended side-effects.
* Cancel reading from stdin on Ctrl-C This is essentially a copy-paste implementation of the ideas presented in this comment here: golang/go#20280 (comment) It fixes #775 and helps with the issue described in #793 (comment). Not sure if it has unintended side-effects. * Add comments and remove interface * update changelog Co-authored-by: BolajiOlajide <[email protected]>
* Cancel reading from stdin on Ctrl-C This is essentially a copy-paste implementation of the ideas presented in this comment here: golang/go#20280 (comment) It fixes #775 and helps with the issue described in #793 (comment). Not sure if it has unintended side-effects. * Add comments and remove interface * update changelog Co-authored-by: BolajiOlajide <[email protected]>
Closes #775
Test plan
Confirm
Ctrl + C
terminates thesrc batch preview -f -
command.