os.fdopen() issue in Python 3.1?

MRAB python at mrabarnett.plus.com
Tue Mar 2 12:32:40 EST 2010


Albert Hopkins wrote:
> I have a snippet of code that looks like this:
> 
>         pid, fd = os.forkpty()
>         if pid == 0:
>             subprocess.call(args)
>         else:
>             input = os.fdopen(fd).read()
>         ...
> 
> 
> This seems to work find for CPython 2.5 and 2.6 on my Linux system.
> However, with CPython 3.1 I get:
> 
>             input = os.fdopen(fd).read()
>         IOError: [Errno 5] Input/output error
> 
> Is there something wrong in Python 3.1?  Is this the correct way to do
> this (run a process in a pseudo-tty and read it's output) or is there
> another way I should/could be doing this?
> 
The documentation also mentions the 'pty' module. Have you tried that
instead?



More information about the Python-list mailing list