diff options
author | Thierry Carrez <thierry@openstack.org> | 2012-09-20 14:42:53 +0200 |
---|---|---|
committer | Thierry Carrez <thierry@openstack.org> | 2012-09-20 15:22:47 +0200 |
commit | 30fe8a4e3c53438bbfb24ba882b3a37c65440e72 (patch) | |
tree | 79aadccc86dd62a57fa823f3728a5a5c0396ebd4 /bin | |
parent | 3c3de4356aca19f8f47d1dd08e363accb857662b (diff) | |
download | neutron-30fe8a4e3c53438bbfb24ba882b3a37c65440e72.tar.gz |
Restore SIGPIPE default action for subprocesses
Python ignores SIGPIPE on startup, because it prefers to check every
write and raise an IOError exception rather than taking the signal. Most
Unix subprocesses don't expect to work this way. This patch (adapted
from Colin Watson's post at http://tinyurl.com/2a7mzh5) sets SIGPIPE
back to the default action for quantum.agent.linux.utils.execute,
quantum.common.utils.execute and quantum-rootwrap created subprocesses.
Fixes bug 1053364
Change-Id: Ib805f1f8846c245b75a5ea64278c840b823c1fb2
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/quantum-rootwrap | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/quantum-rootwrap b/bin/quantum-rootwrap index bb7fbc0d5d..96939ae2ff 100755 --- a/bin/quantum-rootwrap +++ b/bin/quantum-rootwrap @@ -38,6 +38,7 @@ import ConfigParser import os +import signal import subprocess import sys @@ -47,6 +48,12 @@ RC_NOCOMMAND = 98 RC_BADCONFIG = 97 +def _subprocess_setup(): + # Python installs a SIGPIPE handler by default. This is usually not what + # non-Python subprocesses expect. + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + + if __name__ == '__main__': # Split arguments, require at least a command execname = sys.argv.pop(0) @@ -84,6 +91,7 @@ if __name__ == '__main__': stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, + preexec_fn=_subprocess_setup, env=filtermatch.get_environment(userargs)) obj.wait() sys.exit(obj.returncode) |