Skip to content

Commit 1f481fd

Browse files
authored
gh-119273: Don't run test_ioctl in a process group (#119275)
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a process group (using setsid()). Previously, tests using TTY were skipped.
1 parent 055c739 commit 1f481fd

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Lib/test/libregrtest/run_workers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,20 @@ def _kill(self) -> None:
142142
return
143143
self._killed = True
144144

145-
if USE_PROCESS_GROUP:
145+
use_killpg = USE_PROCESS_GROUP
146+
if use_killpg:
147+
parent_sid = os.getsid(0)
148+
sid = os.getsid(popen.pid)
149+
use_killpg = (sid != parent_sid)
150+
151+
if use_killpg:
146152
what = f"{self} process group"
147153
else:
148154
what = f"{self} process"
149155

150156
print(f"Kill {what}", file=sys.stderr, flush=True)
151157
try:
152-
if USE_PROCESS_GROUP:
158+
if use_killpg:
153159
os.killpg(popen.pid, signal.SIGKILL)
154160
else:
155161
popen.kill()

Lib/test/libregrtest/worker.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515

1616
USE_PROCESS_GROUP = (hasattr(os, "setsid") and hasattr(os, "killpg"))
17+
NEED_TTY = set('''
18+
test_ioctl
19+
'''.split())
1720

1821

1922
def create_worker_process(runtests: WorkerRunTests, output_fd: int,
@@ -47,7 +50,10 @@ def create_worker_process(runtests: WorkerRunTests, output_fd: int,
4750
close_fds=True,
4851
cwd=work_dir,
4952
)
50-
if USE_PROCESS_GROUP:
53+
54+
# Don't use setsid() in tests using TTY
55+
test_name = runtests.tests[0]
56+
if USE_PROCESS_GROUP and test_name not in NEED_TTY:
5157
kwargs['start_new_session'] = True
5258

5359
# Pass json_file to the worker process
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a
2+
process group (using ``setsid()``). Previously, tests using TTY were
3+
skipped. Patch by Victor Stinner.

0 commit comments

Comments
 (0)