summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2003-05-05 02:59:40 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2003-05-05 02:59:40 +0000
commitb33a70d1e6b8f0dfeeba35b9664942e7d942614d (patch)
tree90a88889da8bb3dbbcca17ae940c3e5508fb35e1
parentf3b04f3717b9cf542aa9f865b913654c37e316d0 (diff)
downloadpexpect-b33a70d1e6b8f0dfeeba35b9664942e7d942614d.tar.gz
Nothing fucking works on Solaris...
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@190 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r--pexpect/my_forkpty.py22
1 files 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. */