summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/nova-rootwrap9
-rw-r--r--nova/utils.py8
2 files changed, 17 insertions, 0 deletions
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)
diff --git a/nova/utils.py b/nova/utils.py
index f2642f07c..015ff915a 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -31,6 +31,7 @@ import random
import re
import shlex
import shutil
+import signal
import socket
import struct
import sys
@@ -112,6 +113,12 @@ def vpn_ping(address, port, timeout=0.05, session_id=None):
return server_sess
+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)
+
+
def execute(*cmd, **kwargs):
"""Helper method to execute command with optional retry.
@@ -180,6 +187,7 @@ def execute(*cmd, **kwargs):
stdout=_PIPE,
stderr=_PIPE,
close_fds=True,
+ preexec_fn=_subprocess_setup,
shell=shell)
result = None
if process_input is not None: