diff options
Diffstat (limited to 'Lib/test/test_ioctl.py')
-rw-r--r-- | Lib/test/test_ioctl.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py index 7fc9c08..51da6a3 100644 --- a/Lib/test/test_ioctl.py +++ b/Lib/test/test_ioctl.py @@ -7,9 +7,17 @@ get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature try: tty = open("/dev/tty", "r") - tty.close() except IOError: raise unittest.SkipTest("Unable to open /dev/tty") +else: + # Skip if another process is in foreground + r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ") + tty.close() + rpgrp = struct.unpack("i", r)[0] + if rpgrp not in (os.getpgrp(), os.getsid(0)): + raise unittest.SkipTest("Neither the process group nor the session " + "are attached to /dev/tty") + del tty, r, rpgrp try: import pty |