Skip to content

Kill PTY I/O thread when we are done with it #497

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

Merged
merged 1 commit into from
Nov 13, 2016

Conversation

misterbyrne
Copy link
Contributor

@misterbyrne misterbyrne commented Oct 12, 2016

Sometimes the PTY slave can be closed, causing an unhandled exception in
the thread which is calling master.read (socket closed).

This change kills the thread before this happens.

This solves #396 for the test case included
(since this exception was causing Spring to hang)

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @jonleighton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@misterbyrne misterbyrne force-pushed the ab/kill-thread branch 2 times, most recently from e5349c9 to bf363c3 Compare November 3, 2016 21:47
Sometimes the PTY slave can be closed, causing an unhandled exception in
the thread which is calling `master.read` (socket closed).

This change kills the thread before this happens.

Related to rails#396
 (since this exception was causing Spring to hang)
@@ -295,10 +295,11 @@ def print_exception(stream, error)
def with_pty
PTY.open do |master, slave|
[STDOUT, STDERR, STDIN].each { |s| s.reopen slave }
Thread.new { master.read }
reader_thread = Spring.failsafe_thread { master.read }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've switched to using Spring.failsafe_thread here for consistency

@misterbyrne misterbyrne mentioned this pull request Nov 7, 2016
@misterbyrne
Copy link
Contributor Author

@jonleighton Does this look okay to you?

@jonleighton
Copy link
Member

Sorry, I haven't got round to reviewing it yet, but it's on my list and hasn't been forgotten.

@jonleighton jonleighton merged commit 5034437 into rails:master Nov 13, 2016
mikesea referenced this pull request in mikesea/spring Jan 19, 2017
@mikesea
Copy link

mikesea commented Jan 19, 2017

@jonleighton could you please release a new version to rubygems? i haven't had any issues with spring hanging since using this version

@jonleighton
Copy link
Member

@mikesea done

@misterbyrne misterbyrne deleted the ab/kill-thread branch August 4, 2021 14:29
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.

4 participants