-
Notifications
You must be signed in to change notification settings - Fork 272
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
Add POSIX compliant ctrl-c handling #912
Conversation
Thanks @matthewess, LGTM. Didn't notice it was ready for review. For all of us who haven't looked closely at the issue and maybe haven't tried it out, could you add a comment in the PR to describe:
Thanks again! |
LGTM, I think this is ready to merge once conflicts are resolved. @aryairani, in a nutshell, it changes the default behavior of the GHC runtime (translate the first SIGINT into a Elsewhere in the commandline main you're catching |
x -> pure x | ||
x -> pure x) `catch` interruptHandler | ||
interruptHandler (asyncExceptionFromException -> Just UserInterrupt) = awaitInput | ||
interruptHandler _ = pure $ Right QuitI |
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.
I think it would probably be more correct to re-throw non UserInterrupt
exceptions rather than just quit.
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.
Should we wait on this?
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.
I think it could be fixed up post-merge, it's good enuf ;)
added a bit more context but @mitchellwrosen has got it. @aryairani yes, the remaining work is Windows compatibility, I believe. but as mitchell called out there should probably be more delicate handling of non |
Great! Thanks! |
If you wouldn’t mind creating tickets to track the remaining work, that would be awesome. :) |
first pass at addressing #872
based on/cribbed from ghci
the main contribution of this feature is more user-friendly signal handling, particularly making it so that
ucm
responds to SIGINT similarly to other shells, like ghci. if you're typing some input and hit^c
, you will now cancel that input and be given a new line to type on. you can also cancel execution/evaluation of running code inucm
the same way.^d
will emit an EOF that will kill the shell the way^c
used to.this only handles posix signals at the moment, but could be feasibly be extended with the same (CPP-based) windows handling that ghci uses.
i haven't made many contributions to codebases this size, so let me know if some of this would be better added somewhere else or packaged up in a more modular way.