GeezerVison is showing github.com — gh-119273: Don't run test_ioctl in a process group (#119275) · estyxx/cpython@e2d80b1
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Lib/test/libregrtest/run_workers.py +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -142,14 +142,20 @@ def _kill(self) -> None: |
142 | 142 | return |
143 | 143 | self._killed = True |
144 | 144 |
|
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: |
146 | 152 | what = f"{self} process group" |
147 | 153 | else: |
148 | 154 | what = f"{self} process" |
149 | 155 |
|
150 | 156 | print(f"Kill {what}", file=sys.stderr, flush=True) |
151 | 157 | try: |
152 | | - if USE_PROCESS_GROUP: |
| 158 | + if use_killpg: |
153 | 159 | os.killpg(popen.pid, signal.SIGKILL) |
154 | 160 | else: |
155 | 161 | popen.kill() |
|
Collapse file
Copy file name to clipboardExpand all lines: Lib/test/libregrtest/worker.py +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
14 | 14 |
|
15 | 15 |
|
16 | 16 | USE_PROCESS_GROUP = (hasattr(os, "setsid") and hasattr(os, "killpg")) |
| 17 | +NEED_TTY = set(''' |
| 18 | + test_ioctl |
| 19 | +'''.split()) |
17 | 20 |
|
18 | 21 |
|
19 | 22 | def create_worker_process(runtests: WorkerRunTests, output_fd: int, |
@@ -47,7 +50,10 @@ def create_worker_process(runtests: WorkerRunTests, output_fd: int, |
47 | 50 | close_fds=True, |
48 | 51 | cwd=work_dir, |
49 | 52 | ) |
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: |
51 | 57 | kwargs['start_new_session'] = True |
52 | 58 |
|
53 | 59 | # Pass json_file to the worker process |
|
Collapse file
Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 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. |