Skip to content
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

Fix endless while loop on EOF for pty process #151

Merged
merged 1 commit into from
Dec 27, 2018

Conversation

jthacker
Copy link
Contributor

os.read spec says that when EOF is reached by the fd, an empty bytes
object is returned.

os.read spec says that when EOF is reached by the fd, an empty bytes
object is returned.
@bugy
Copy link
Owner

bugy commented Dec 27, 2018

Hi @jthacker , thanks for the PR! Looks like a critical bug. but I'm curisous why nobody saw this issue before. Let me play a little bit with a current code to check why it's working (or if I'm missing something).
After that I'll merge your PR.

@jthacker
Copy link
Contributor Author

@bugy I am running this on OSX, which might play a part there.

@bugy
Copy link
Owner

bugy commented Dec 27, 2018

The reason why it's working on linux: non-blocking read should fail with an error if there is no data to read: example documentation
For OSX it should be the same behaviour (according to this link, O_NONBLOCK description)

For that reason there is a code in infinite loop:

except BlockingIOError:
  break

Merging your PR should be fine, to be on safer side. But I still need to find out the reason why BlockingIOError (or any other error) is not thrown. It could be, for example, that non_blocking flag is not set at all, which will influence performance and can cause some other issues

Anyway, thank you for investigating and fixing the issue!

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.

2 participants