https://github.com/python/cpython/commit/1f481fd3275dbc12a88c16129621de19ea20e4ca
commit: 1f481fd3275dbc12a88c16129621de19ea20e4ca
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-05-29T12:44:09Z
summary:
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.
files:
A Misc/NEWS.d/next/Tests/2024-05-20-18-06-31.gh-issue-119273.hf-yhX.rst
M Lib/test/libregrtest/run_workers.py
M Lib/test/libregrtest/worker.py
diff --git a/Lib/test/libregrtest/run_workers.py
b/Lib/test/libregrtest/run_workers.py
index 235047cf2e563c..a71050e66db3bd 100644
--- a/Lib/test/libregrtest/run_workers.py
+++ b/Lib/test/libregrtest/run_workers.py
@@ -142,14 +142,20 @@ def _kill(self) -> None:
return
self._killed = True
- if USE_PROCESS_GROUP:
+ use_killpg = USE_PROCESS_GROUP
+ if use_killpg:
+ parent_sid = os.getsid(0)
+ sid = os.getsid(popen.pid)
+ use_killpg = (sid != parent_sid)
+
+ if use_killpg:
what = f"{self} process group"
else:
what = f"{self} process"
print(f"Kill {what}", file=sys.stderr, flush=True)
try:
- if USE_PROCESS_GROUP:
+ if use_killpg:
os.killpg(popen.pid, signal.SIGKILL)
else:
popen.kill()
diff --git a/Lib/test/libregrtest/worker.py b/Lib/test/libregrtest/worker.py
index f8b8e45eca3276..15d32b5baa04d0 100644
--- a/Lib/test/libregrtest/worker.py
+++ b/Lib/test/libregrtest/worker.py
@@ -14,6 +14,9 @@
USE_PROCESS_GROUP = (hasattr(os, "setsid") and hasattr(os, "killpg"))
+NEED_TTY = set('''
+ test_ioctl
+'''.split())
def create_worker_process(runtests: WorkerRunTests, output_fd: int,
@@ -47,7 +50,10 @@ def create_worker_process(runtests: WorkerRunTests,
output_fd: int,
close_fds=True,
cwd=work_dir,
)
- if USE_PROCESS_GROUP:
+
+ # Don't use setsid() in tests using TTY
+ test_name = runtests.tests[0]
+ if USE_PROCESS_GROUP and test_name not in NEED_TTY:
kwargs['start_new_session'] = True
# Pass json_file to the worker process
diff --git
a/Misc/NEWS.d/next/Tests/2024-05-20-18-06-31.gh-issue-119273.hf-yhX.rst
b/Misc/NEWS.d/next/Tests/2024-05-20-18-06-31.gh-issue-119273.hf-yhX.rst
new file mode 100644
index 00000000000000..905b4e3a1c9043
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-05-20-18-06-31.gh-issue-119273.hf-yhX.rst
@@ -0,0 +1,3 @@
+Python test runner no longer runs tests using TTY (ex: test_ioctl) in a
+process group (using ``setsid()``). Previously, tests using TTY were
+skipped. Patch by Victor Stinner.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]