Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue32844

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:subprocess may incorrectly redirect a low fd to stderr if another low fd is closed
Type:behaviorStage:resolved
Components:Extension Modules, Library (Lib)Versions:Python 3.7, Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: gregory.p.smith, izbyshev, miss-islington
Priority:normalKeywords:patch

Created on2018-02-14 21:10 byizbyshev, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 5689mergedizbyshev,2018-02-14 21:16
PR 6262mergedmiss-islington,2018-03-26 19:49
PR 6263mergedmiss-islington,2018-03-26 19:50
Messages (5)
msg312181 -(view)Author: Alexey Izbyshev (izbyshev)*(Python triager)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.pyimport osimport subprocessimport sysos.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/nullHelloExpected behavior:$ python3 test.py >/dev/null$ python3 test.py 2>/dev/nullHello
msg312182 -(view)Author: Alexey Izbyshev (izbyshev)*(Python triager)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)*(Python committer)Date: 2018-03-26 19:49
New changeset0e7144b064a19493a146af94175a087b3888c37b 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 changeset05455637f3ba9bacd459700f4feab783e5967d69 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 changeset57db13e582ad269d6e067fe934122207cc992739 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
DateUserActionArgs
2022-04-11 14:58:57adminsetgithub: 77025
2018-03-26 21:03:05izbyshevsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-03-26 20:43:48miss-islingtonsetmessages: +msg314481
2018-03-26 20:14:12miss-islingtonsetnosy: +miss-islington
messages: +msg314479
2018-03-26 19:50:46miss-islingtonsetpull_requests: +pull_request5989
2018-03-26 19:49:52miss-islingtonsetpull_requests: +pull_request5988
2018-03-26 19:49:38gregory.p.smithsetmessages: +msg314478
2018-02-14 21:22:06izbyshevsetmessages: +msg312182
2018-02-14 21:16:07izbyshevsetkeywords: +patch
stage: patch review
pull_requests: +pull_request5482
2018-02-14 21:10:48izbyshevcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp