From a694b9e5adec8236ce8b2cd4832f8dc4912de6fc Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Thu, 20 Sep 2012 14:11:38 +0200 Subject: 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 nova.utils.execute and nova-rootwrap created subprocesses. Fixes bug 1053364 Change-Id: I17e1629bb4ef4268515c6734ddb6e12746739c52 --- bin/nova-rootwrap | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bin/nova-rootwrap') diff --git a/bin/nova-rootwrap b/bin/nova-rootwrap index b903f3030..a28205a80 100755 --- a/bin/nova-rootwrap +++ b/bin/nova-rootwrap @@ -34,6 +34,7 @@ import ConfigParser import os +import signal import subprocess import sys @@ -42,6 +43,13 @@ RC_UNAUTHORIZED = 99 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) @@ -77,6 +85,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) -- cgit