diff options
author | Victor Stinner <vstinner@python.org> | 2024-05-29 12:44:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 12:44:09 (GMT) |
commit | 1f481fd3275dbc12a88c16129621de19ea20e4ca (patch) | |
tree | 3f04a9b97a9d0c1a545db9d514b0acddd68bee39 | |
parent | 055c739536ad63b55ad7cd0b91ccacc33064fe11 (diff) | |
download | cpython-1f481fd3275dbc12a88c16129621de19ea20e4ca.zip cpython-1f481fd3275dbc12a88c16129621de19ea20e4ca.tar.gz cpython-1f481fd3275dbc12a88c16129621de19ea20e4ca.tar.bz2 |
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.
-rw-r--r-- | Lib/test/libregrtest/run_workers.py | 10 | ||||
-rw-r--r-- | Lib/test/libregrtest/worker.py | 8 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2024-05-20-18-06-31.gh-issue-119273.hf-yhX.rst | 3 |
3 files changed, 18 insertions, 3 deletions
diff --git a/Lib/test/libregrtest/run_workers.py b/Lib/test/libregrtest/run_workers.py index 235047c..a71050e 100644 --- a/Lib/test/libregrtest/run_workers.py +++ b/Lib/test/libregrtest/run_workers.py @@ -142,14 +142,20 @@ class WorkerThread(threading.Thread): 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 f8b8e45..15d32b5 100644 --- a/Lib/test/libregrtest/worker.py +++ b/Lib/test/libregrtest/worker.py @@ -14,6 +14,9 @@ from .utils import ( 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 0000000..905b4e3 --- /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. |