Created on 2018-02-14 21:10 by izbyshev, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 5689 | merged | izbyshev, 2018-02-14 21:16 | |
| PR 6262 | merged | miss-islington, 2018-03-26 19:49 | |
| PR 6263 | merged | miss-islington, 2018-03-26 19:50 | |
| Messages (5) | |||
|---|---|---|---|
| msg312181 - (view) | Author: Alexey Izbyshev (izbyshev) * | Date: 2018-02-14 21:10 | |
When redirecting, subprocess attempts to achieve the following state: each fd to be redirected to is less than or equal to the fd it is redirected from, which is necessary because redirection occurs in the ascending order of destination descriptors. It fails to do so if a low fd (< 2) is redirected to stderr and another low fd is closed, which may lead to an incorrect redirection, for example:
$ cat test.py
import os
import subprocess
import sys
os.close(0)
subprocess.call([sys.executable, '-c',
'import sys; print("Hello", file=sys.stderr)'],
stdin=2,
stderr=1)
$ python3 test.py 2>/dev/null
$ python3 test.py >/dev/null
Hello
Expected behavior:
$ python3 test.py >/dev/null
$ python3 test.py 2>/dev/null
Hello
|
|||
| msg312182 - (view) | Author: Alexey Izbyshev (izbyshev) * | Date: 2018-02-14 21:22 | |
Note that the PR doesn't attempt to fix leaking of low dup'ed fds to the child. I'll file a separate report for that in a while. |
|||
| msg314478 - (view) | Author: Gregory P. Smith (gregory.p.smith) * | Date: 2018-03-26 19:49 | |
New changeset 0e7144b064a19493a146af94175a087b3888c37b by Gregory P. Smith (Alexey Izbyshev) in branch 'master': bpo-32844: Fix a subprocess misredirection of a low fd (GH5689) https://github.com/python/cpython/commit/0e7144b064a19493a146af94175a087b3888c37b |
|||
| msg314479 - (view) | Author: miss-islington (miss-islington) | Date: 2018-03-26 20:14 | |
New changeset 05455637f3ba9bacd459700f4feab783e5967d69 by Miss Islington (bot) in branch '3.7': bpo-32844: Fix a subprocess misredirection of a low fd (GH5689) https://github.com/python/cpython/commit/05455637f3ba9bacd459700f4feab783e5967d69 |
|||
| msg314481 - (view) | Author: miss-islington (miss-islington) | Date: 2018-03-26 20:43 | |
New changeset 57db13e582ad269d6e067fe934122207cc992739 by Miss Islington (bot) in branch '3.6': bpo-32844: Fix a subprocess misredirection of a low fd (GH5689) https://github.com/python/cpython/commit/57db13e582ad269d6e067fe934122207cc992739 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:57 | admin | set | github: 77025 |
| 2018-03-26 21:03:05 | izbyshev | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2018-03-26 20:43:48 | miss-islington | set | messages: + msg314481 |
| 2018-03-26 20:14:12 | miss-islington | set | nosy:
+ miss-islington messages: + msg314479 |
| 2018-03-26 19:50:46 | miss-islington | set | pull_requests: + pull_request5989 |
| 2018-03-26 19:49:52 | miss-islington | set | pull_requests: + pull_request5988 |
| 2018-03-26 19:49:38 | gregory.p.smith | set | messages: + msg314478 |
| 2018-02-14 21:22:06 | izbyshev | set | messages: + msg312182 |
| 2018-02-14 21:16:07 | izbyshev | set | keywords:
+ patch stage: patch review pull_requests: + pull_request5482 |
| 2018-02-14 21:10:48 | izbyshev | create | |