-
Notifications
You must be signed in to change notification settings - Fork 477
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
Hitting ^D in an 'interact()' causes endless printing of 'exit' #49
Comments
I think this comment points to the issue:
In interact, it's not using |
Oh, no, it's simpler than that. You're using fdpexpect, so the fdspawn object doesn't know about the child process, only the file handle you've given it. The pty continues to exist after the process has died, so it has no way of knowing to stop reading. Is there a reason you (or rather shutit) are replicating the functionality of pexpect? The easiest way to fix this would be to use the main
|
Good point. I think this behaviour is probably historical, I'll need see if I can remember why I wrote it like that... However, it doesn't change the fact that it terminates correctly in 2.4. This contradicts "[...] it has no way of knowing to stop reading." Traceback (most recent call last):
File "test.py", line 21, in <module>
c.interact()
File "/usr/lib/python2.7/dist-packages/pexpect.py", line 1492, in interact
self.__interact_copy(escape_character, input_filter, output_filter)
File "/usr/lib/python2.7/dist-packages/pexpect.py", line 1520, in __interact_copy
data = self.__interact_read(self.child_fd)
File "/usr/lib/python2.7/dist-packages/pexpect.py", line 1510, in __interact_read
return os.read(fd, 1000)
OSError: [Errno 5] Input/output error |
Turns out the reason I did this initially was to connect pexpect to paramiko (which happens to expose a fd for the ssh terminal). I'm going to do it the way you suggested (thanks!) for shutit. I'll leave this issue open, but I wouldn't call it a huge priority. |
Well, I wouldn't quite call throwing an error 'terminating correctly', but I take your point. Pexpect now catches that error, but it should probably stop looping when it does. |
tested on centos using script by @aidanhs, not that doing your own pty.fork() is really recommended if you're going to use interact Otherwise, tested also using traditional use of interact, though that worked fine previously -- it still works fine, now. With this, the test script provided by aidnhs now exits fine. I would be interested in a test case and a more precise use-case.
Yes, this bug was introduced by c7a180a -- @takluyver, see my pull request -- how does this match to what you intended with this comment? |
#72 is now merged, closing this. |
Run the following code:
You get a bash session, it works, you can do things.
Now, instead of hitting ^], hit ^D - observe the endless printing of 'exit' and your now locked-up terminal.
Going backwards through pypi versions, I can see this has definitely been broken since 3.0, but was working (it raised an exception instead of printing the same output forever) in 2.4
The text was updated successfully, but these errors were encountered: