From b33a70d1e6b8f0dfeeba35b9664942e7d942614d Mon Sep 17 00:00:00 2001 From: noah Date: Mon, 5 May 2003 02:59:40 +0000 Subject: Nothing fucking works on Solaris... git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@190 656d521f-e311-0410-88e0-e7920216d269 --- pexpect/my_forkpty.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pexpect/my_forkpty.py b/pexpect/my_forkpty.py index a1c6b37..b63e27d 100644 --- a/pexpect/my_forkpty.py +++ b/pexpect/my_forkpty.py @@ -1,4 +1,4 @@ -import os, fcntl, termios, struct +import os, fcntl, termios import time def my_forkpty(): @@ -14,17 +14,18 @@ def my_forkpty(): if pid == -1: raise ExceptionPexpect("Forkpty failed") elif pid == 0: # Child - if 'TIOCNOTTY' in dir(termios): - # /* Some platforms require an explicit detach of the + if hasattr(termios, 'TIOCNOTTY'): + # Some platforms require an explicit detach of the # current controlling tty before closing stdin, stdout, stderr. - # OpenBSD says that this is obsolete, but doesn't hurt. */ - fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY) - if fd >= 0: - s = struct.pack("H", 0) - fcntl.ioctl(fd, termios.TIOCNOTTY, s); + # OpenBSD says that this is obsolete, but doesn't hurt. + try: + fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY) + except: + pass + else: #if fd >= 0: + fcntl.ioctl(fd, termios.TIOCNOTTY, 0) os.close(fd) - # The setsid() system call will place the process into its own session # which has the effect of disassociating it from the controlling terminal. # This is known to be true for OpenBSD. @@ -41,8 +42,7 @@ def my_forkpty(): if 'TIOCSCTTY' in dir(termios): # Make the pseudo terminal the controlling terminal for this process # (the process must not currently have a controlling terminal). - s = struct.pack("H", 0) - if fcntl.ioctl(slave_fd, termios.TIOCSCTTY, s) < 0: + if fcntl.ioctl(slave_fd, termios.TIOCSCTTY, '') < 0: raise ExceptionPexpect("Forkpty failed") # # Verify that we can open to the slave pty file. */ -- cgit v1.2.1