Skip to content
Snippets Groups Projects
Commit 339fe663 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(Spawn._read): Override the default method to handle EIO properly.

(Spawn.kill): New method.
parent 47717d0d
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,7 @@
import os
import sys
import pty
import errno
import fcntl
import pcl_expect
......@@ -226,6 +227,20 @@ class Spawn(pcl_expect.Expectable):
pcl_expect.debug("sending \"%s\" to fd %d" % (s, self.fileno()))
os.write(self.fileno(), s)
def _read(self):
# When reading from a pty, at least under Linux, you get EIO
# when the process dies. Treat this as a normal end-of-file.
try:
return pcl_expect.Expectable._read(self)
except OSError, err:
if err.errno == errno.EIO:
return "", True
raise
def kill(self, sig):
"""Send signal SIG to the child process."""
os.kill(self.__child_pid, sig)
def close(self):
"""Close the pty and wait for the child to die.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment