pty code from 2.3.4 not working in 2.3.5
Adriaan Renting
renting at astron.nl
Thu Jun 16 11:32:11 EDT 2005
I hope you might be able to help me,
as I can't find the cause of my problem.
My sysadmin has upgraded Python from 2.3.4 (SuSE 9.2) to 2.3.5 (from
python.org) Now my code for running an external program no longer works.
My code is largely based on pexcpect.py and quite complex, but the
example below reproduces my problem:
-------------------------------------------------
import os, select, pty
pid, fd = pty.fork()
fd_eof = 0
if pid == 0:
os.execvp('ls',['ls'])
else:
while not fd_eof:
ready = select.select([fd], [], [], 0.25)
if fd in ready[0]:
text = os.read(fd, 1024)
if text == '':
fd_eof = 1
else: print text
-------------------------------------------------------------
In 2.3.4 this exits with an exception OSError: [Errno 5] Input/output
error
after showing the 'ls' output, in 2.3.5 this just keeps running
indefinately. In my own code I handle the OSError by setting fd_eof=1,
after the while I do some waitpid, but this is all irrelevant to the
problem I think.
pty.py doesn't seem to have changed from 2.3.4 to 2.3.5
Do you have any idea what the cause of my program no longer finishing
can be, and what I am doing wrong?
Thank you,
Adriaan Renting.
More information about the Python-list
mailing list