RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 667431 - Python Popen.communicate is unable to collect stderr, stdout and returncode for a short lived processes
Summary: Python Popen.communicate is unable to collect stderr, stdout and returncode f...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: python
Version: 6.0
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: ---
Assignee: Dave Malcolm
QA Contact: Petr Šplíchal
URL:
Whiteboard:
Depends On:
Blocks: 967590
TreeView+ depends on / blocked
 
Reported: 2011-01-05 15:33 UTC by Federico Simoncelli
Modified: 2016-06-01 01:40 UTC (History)
8 users (show)

Fixed In Version: python-2.6.6-22.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 734841 967590 (view as bug list)
Environment:
Last Closed: 2011-12-06 10:23:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
test_shortprocess.py (261 bytes, text/x-python)
2011-01-05 15:33 UTC, Federico Simoncelli
no flags Details
subprocess-sigpipe-el6.patch (1020 bytes, patch)
2011-01-05 15:35 UTC, Federico Simoncelli
no flags Details | Diff
subprocess-sigpipe-fc14.patch (1.64 KB, patch)
2011-01-05 15:36 UTC, Federico Simoncelli
no flags Details | Diff
Backport of the upstream patch (9.75 KB, patch)
2011-04-07 19:47 UTC, Dave Malcolm
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Python 10963 0 None None None Never
Red Hat Bugzilla 524836 0 high CLOSED python subprocess have errors in signal handling 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2011:1564 0 normal SHIPPED_LIVE python bug fix and enhancement update 2011-12-06 00:39:12 UTC

Description Federico Simoncelli 2011-01-05 15:33:54 UTC
Created attachment 471885 [details]
test_shortprocess.py

Description of problem:
Using Popen.communicate over a short-lived process results in a broken pipe exception (errno 32) which will prevent to collect the stderr, stdout and returncode of the dead process.

Version-Release number of selected component (if applicable):
# rpm -qf /usr/lib64/python2.6/subprocess.py
python-2.6.5-3.el6.x86_64

How reproducible:
$ python test_shortprocess.py

Actual results:
None
Traceback (most recent call last):
  File "test_shortprocess.py", line 7, in <module>
    out, err = p.communicate(2**20 * '\0')
  File "/usr/lib64/python2.7/subprocess.py", line 740, in communicate
    return self._communicate(input)
  File "/usr/lib64/python2.7/subprocess.py", line 1256, in _communicate
    stdout, stderr = self._communicate_with_poll(input)
  File "/usr/lib64/python2.7/subprocess.py", line 1319, in _communicate_with_poll
    input_offset += os.write(fd, chunk)
OSError: [Errno 32] Broken pipe

Expected results:
$ python test_process-fix.py 
dd: unrecognized operand `option=crash'
Try `dd --help' for more information.
1

Comment 1 Federico Simoncelli 2011-01-05 15:35:17 UTC
Created attachment 471886 [details]
subprocess-sigpipe-el6.patch

Proposed patch for el6.

Comment 2 Federico Simoncelli 2011-01-05 15:36:06 UTC
Created attachment 471887 [details]
subprocess-sigpipe-fc14.patch

Proposed patch for fc14.

Comment 4 Dave Malcolm 2011-01-20 20:30:21 UTC
Thanks for filing this bug.

I've filed it within the upstream python tracker as:
  http://bugs.python.org/issue10963

The patch I've attached there slightly reworks the fix, and adds a unit test.

However, I'm not fully convinced that this is the correct approach, in that the change could mask stdin under-reads from poorly-written subprocesses that exit with failures but don't return with a non-zero exit code (alas, too many programs exit with 0 even when exiting with an error).

Comment 10 RHEL Program Management 2011-02-22 21:35:00 UTC
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request.

Comment 16 Dave Malcolm 2011-04-07 19:47:54 UTC
Created attachment 490627 [details]
Backport of the upstream patch

The attached patch is a backport of the patch applied upstream to 2.7 to the somewhat modified 2.6.6 currently in RHEL 6.1

The upstream patch contained two new test cases; I've added some additional cases over and above those ones.  All of test/test_subprocess.py passes on my test build (x86_64; python-2.6.6-17 + this new patch)

I've also tested the patched version using attachment 471885 [details] (from comment #0), and it fixes the reported traceback, giving the expected results.

Comment 24 errata-xmlrpc 2011-12-06 10:23:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1564.html


Note You need to log in before you can comment on or make changes to this bug.