Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39d795d

Browse files
committed
Issue #7564: Skip test_ioctl if another process is attached to /dev/tty.
1 parent e7eaec6 commit 39d795d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/test/test_ioctl.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77

88
try:
99
tty = open("/dev/tty", "r")
10-
tty.close()
1110
except IOError:
1211
raise unittest.SkipTest("Unable to open /dev/tty")
12+
else:
13+
# Skip if another process is in foreground
14+
r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
15+
tty.close()
16+
rpgrp = struct.unpack("i", r)[0]
17+
if rpgrp not in (os.getpgrp(), os.getsid(0)):
18+
raise unittest.SkipTest("Neither the process group nor the session "
19+
"are attached to /dev/tty")
20+
del tty, r, rpgrp
1321

1422
try:
1523
import pty

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ Tools/Demos
136136
Tests
137137
-----
138138

139+
- Issue #7564: Skip test_ioctl if another process is attached to /dev/tty.
140+
139141
- Issue #8433: Fix test_curses failure with newer versions of ncurses.
140142

141143
- Issue #9496: Provide a test suite for the rlcompleter module. Patch by

0 commit comments

Comments
 (0)