Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Conversation

@jdelStrother
Copy link

At the moment, if you hit Ctrl-C twice to abort a run, rspec uses exit! to exit, so at_exit handlers aren't run. This means, for example, that Capybara doesn't send a quit message to its browser, so I often end up with dead Google Chrome processes lying around.

I'm not sure what the rational was for choosing exit! vs exit (/cc @dchelimsky ?), so I'm not 100% convinced this PR is correct/desired behaviour. Would welcome any thoughts on it.

@myronmarston
Copy link
Member

This is intentional. To exit with proper cleanup/shutdown, hit ctrl-c once. RSpec attempts to gracefully shutdown after the first ctrl-c. You can hit ctrl-c a 2nd time to force it to immediately shutdown, without any cleanup. We use exit! in this case because it forces an immediate exit, where as exit triggers at_exit handlers, which, as they run user code, could hang and prevent the interpreter from immediately exiting. So I don't think it would be appropriate to use exit on the 2nd ctrl-c, as it would go against the goal of immediately exiting.

Is there some reason why a single ctrl-c isn't working properly for you? Maybe there's something we could improve there so it exits more quickly while retaining the cleanup it performs.

@jdelStrother
Copy link
Author

I use double-ctrl-c when I’ve already seen what I want from a run and don’t care about waiting for the current spec to finish. I kinda think it’s a weird thing for rspec to provide - eg rake doesn’t override interrupt signals on the off-chance that someone’s at_exit handler might be misbehaving. Why do you think rspec should?

@xaviershay
Copy link
Member

I believe historically we've had sufficient issues with rspec not exiting at all in response to ctrl+c that we made it follow current behaviour.

@JonRowe
Copy link
Member

JonRowe commented Jan 5, 2018

I agree with @myronmarston and @xaviershay here, the current behaviour is desirable, you can achieve your goals by only hitting ctrl-c once.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants