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

Race condition in pexpect.spawn() on Solaris 11 #206

Closed
reynir opened this issue Apr 17, 2015 · 4 comments
Closed

Race condition in pexpect.spawn() on Solaris 11 #206

reynir opened this issue Apr 17, 2015 · 4 comments
Assignees

Comments

@reynir
Copy link

reynir commented Apr 17, 2015

It seems it is possible in certain situations for the child_fd to be closed before the windowsize can be set. I tried putting in a print before, and the file descriptor looks OK (i.e. it's not -1).

import pexpect
pexpect.spawn("/bin/true")

Relevant stack trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/export/home/rbj/.local/lib/python2.6/site-packages/pexpect/__init__.py", line 511, in __init__
    self._spawn(command, args)
  File "/export/home/rbj/.local/lib/python2.6/site-packages/pexpect/__init__.py", line 674, in _spawn
    self.setwinsize(24, 80)
  File "/export/home/rbj/.local/lib/python2.6/site-packages/pexpect/__init__.py", line 1602, in setwinsize
    fcntl.ioctl(self.fileno(), TIOCSWINSZ, s)
IOError: [Errno 6] No such device or address

This is a corner case that probably doesn't affect many users (if any). You can download a Solaris 11.2 VirtualBox image if you want to test it yourself. I have the CPU throttled to 50% on my VM - that might make the race condition more obvious.

@jquast jquast added the bug label Apr 17, 2015
@jquast jquast self-assigned this Apr 17, 2015
@takluyver
Copy link
Member

I guess if the child process finishes very quickly, the pty might be destroyed before the parent tries to act on it. We should probably catch and silence that errno.

@jquast
Copy link
Member

jquast commented Apr 24, 2015

Sadly this isn't reproducing on joyent SmartOS (OpenSolaris) with a 0.125 CPU share. I'll try the commercial Solaris, then.

@jquast
Copy link
Member

jquast commented May 1, 2015

this will be resolved in next pexpect release

@jquast
Copy link
Member

jquast commented Sep 21, 2015

Closed 2015-05-20 by release of ptyprocess 0.5, please open new issue if reproducing.

@jquast jquast closed this as completed Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants