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 1117751 - sub processes ignore SIGPIPE
Summary: sub processes ignore SIGPIPE
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Python Maintainers
QA Contact: Branislav Náter
URL:
Whiteboard:
Depends On: 1264667
Blocks: 859169 1110700 1191021 1257613 1267843 1267848
TreeView+ depends on / blocked
 
Reported: 2014-07-09 10:19 UTC by Pádraig Brady
Modified: 2016-07-07 09:43 UTC (History)
15 users (show)

Fixed In Version: python-2.7.5-33.el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 859169
Environment:
Last Closed: 2016-07-07 09:43:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Python 1652 0 None None None Never
Red Hat Bugzilla 1269176 0 urgent CLOSED Hosted engine deploy fails due to Libvirt cannot be started error 2021-02-22 00:41:40 UTC

Internal Links: 1269176

Comment 2 Bohuslav "Slavek" Kabrda 2014-07-09 12:24:38 UTC
So, there are two possible approaches to this issue:
1) Just take the upstream patch and backport it to Python 2.7
2) Use diff between Python 2.7 subprocess.py and subprocess32.py from python-subprocess32.

The first approach is easy, but error-prone. Upstream may have (and they probably did) eventually changed some lines added in this patch - there were either some problems or some improvements were needed. This means that the second approach is better - but python-subprocess32 also has lots of other backported features that, if included in patch for this bug, may break backwards compatibility. So the way we'll proceed here is that we'll do a diff between Python 2.7 subprocess.py and subprocess32.py and keep just the changes that are related to this bug. This will not be easy and we need to make sure it will work, but I think we can do this. I'll add dev_ack+ when we're sure we have the right patch.

Comment 15 Matej Stuchlik 2015-09-16 13:38:51 UTC
We've decided to not reset the signal handler by default. You can have the handler be reset by calling Popen with restore_sigpipe keyword argument set to True.

Comment 26 Pádraig Brady 2016-04-24 21:10:42 UTC
Can you detail _why_ you decided not to set the default for restore_sigpipe to True? I've just hit this issue again (and again a weird failure mode with a program stuck in an infinite loop). Please reconsider the importance of this.

Can anyone think of a use case were people may be relying on getting EPIPE rather than SIGPIPE? Surely if they're relying on that weird behavior they're not relying on python to have set the non standard signal handling, and would do it within the sub process. I explained already in bug #859169 why not having restore_sigpipe=False as the default is next to useless as there are already easy (and more standard) workarounds to apply.

Comment 27 Petr Viktorin (pviktori) 2016-04-26 09:57:36 UTC
In Python 3, the reset is implemented in C code. The backport to Python 2 was done in Python code, which needs to call signal.signal.
But, mod_wsgi with WSGIRestrictSignal replaces signal.signal, so the backport fails in that scenario This is a serious regression for FreeIPA (see bug #1257613).

Adding a restore_sigpipe argument caused breakage in, for example, Gluster (see bug #1267848).

Comment 28 Pádraig Brady 2016-04-26 13:04:38 UTC
Yes I agree the restore_sigpipe argument is problematic and not really useful.

As for generally resetting SIGPIPE I see WSGIRestrictSignal is used for a few reasons including:

"Apache will ensure that the signal SIGPIPE is set to SIG_IGN. If a WSGI application needs to override this, it must ensure that it is reset to SIG_IGN before any Apache code is run. In a multi threaded MPM this would be practically impossible to ensure so it is preferable that the handler for SIG_PIPE also not be changed."

It's a pity python/apache don't set a default empty handler for SIGPIPE,
as that would auto revert to standard handling upon exec().

I suppose we could handle most cases by doing this unconditionally in subprocess.py.

  self.pid = os.fork()
  if self.pid == 0:
    try:
      signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    except:
      pass # maybe warn

thanks for the info

Comment 29 Petr Viktorin (pviktori) 2016-07-07 09:43:09 UTC
The current behavior is not ideal, but the fix introduces regressions, and a workaround is available for software that needs the reset functionality.
Therefore, I unfortunately need to close this as WONTFIX.


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