pty code from 2.3.4 not working in 2.3.5

A

Adriaan Renting

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Sending C-c to Emacs 1

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top