By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

pty code from 2.3.4 not working in 2.3.5

P: n/a
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.

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.