-
Notifications
You must be signed in to change notification settings - Fork 112
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
Suggestion to fix dangling ghc process on double ctrl+c #286
base: master
Are you sure you want to change the base?
Conversation
Aren't you trading a process that leaks a GHC, for one you can't kill with Ctrl-C at all? Both seem like fairly unpleasant options... The other issue is that ghcid is both a library and an executable, but I'm sure with some config we could work around that. |
It does get killed. You just get an error message when you press that second ctrl+c, but other than that it works well.
Yes! An option to make this configurable sounds great. |
I'm confused - can you explain the sequence of events? I hit ctrl-c, that starts terminating GHC how it does now. I hit ctrl-c again, then I go to the handler, and what happens? What if GHC exits cleanly, and what if it stays around? If I hit ctrl-c again, what happens then? (I'm a Windows guy, so signal handlers aren't my area of expertise!) |
Oh, I don't know about signals either, much less in Haskell. This was just an experiment to see ig I could kill the underlying process no matter how many ctrl+c I did. I'll investigate this with my team to see if we can come to a clean PR that works as expected. Thank you! |
Happy to keep this PR open while you do so (up to you) - I agree this seems like a reasonable approach. I'd also suggest you stick to Posix only to start with, since doing whatever you do cross platform will be additional complication. (Although very happy if you can do it cross platform, of course!) |
Sounds good! |
Hello, I've experienced this issue recently, and I think that it would be very useful to fix it 🙂 Basically my computer was becoming unresponsive after using I have a draft commit with a fix 9f1eb0f . My proposal is: don't exit Some notes about my commit:
|
Notes if we do go with @acondolu's code:
|
@ndmitchell I've revisited my commit with your observations ➡️ see acondolu@d299f9a What do you guys think? |
Any chance to get this going? |
@asterite Sorry for giving no thoughts about this, but a lot of time has passed and I lost context on this, plus I won't have time to look at it... so don't wait for my opinion 😄 (in case you were doing so) |
@acondolu does that mean if ghci doesn't exit, ghcid hangs? |
Current state: pressing Ctrl+C twice will make ghcid exit but the underlying ghci dangling, running in the background. Proposed state: after pressing Ctrl+C (once or multiple times) if ghci doesn't exit, ghcid hangs. |
Hi!
This PR is not meant to be merged. Instead, I'd like to open the discussion to find possible solutions to #257
Debugging the code, not fully looking at it, I noticed that when you press ctrl+c once it seems
quit
will be called, which in turn will callinterrupt
and thenghciInterrupt
. However, if you press ctrl+c once again the process will shutdown immediately and a danglingghc
might happen.Just to try things to improve this, I used
installHandler
to trap SIGINT (ctrl+c). When I did that, every time you press ctrl+c, no matter how many times, the handler call will run. So I tried puttingquit
there and it works fine. However, the second time it will print some failure (because we already calledterminateProcess
) but it at least doesn't leave a danglingghc
, so it's already slightly better than the current situation. Ideally the secondctrl+c
would do nothing: just wait for the process to exit, or maybe just ignore the secondctrl+c
, I don't know.Thoughts?
The dangling
ghc
is not a blocker but I'd definitely like to prevent it.