aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-04-24 16:51:21 +0200
committerGuido Günther <agx@sigxcpu.org>2009-04-24 16:51:21 +0200
commit3e4b08ed095b12675b8865893274c65782720fe6 (patch)
tree0fdb67671725df6741f9eb93c8d950e6083567eb
parent54b9da0fe4fe508dfe457f7af9e6c47a698762b6 (diff)
restore default signal handlers before subprocess.call
Closes: #525411
-rw-r--r--gbp/command_wrappers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index 0397a3f7..e000af16 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -10,6 +10,7 @@ import subprocess
import sys
import os
import os.path
+import signal
from errors import GbpError
class CommandExecFailed(Exception):
@@ -37,12 +38,16 @@ class Command(object):
def __call(self, args):
"""simply wraps subprocess.call so we can be verbose"""
+ def default_sigpipe():
+ "restore default signal handler (http://bugs.python.org/issue1652)"
+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
if self.verbose:
print self.cmd, self.args, args
cmd = [ self.cmd ] + self.args + args
if self.shell: # subprocess.call only cares about the first argument if shell=True
cmd = " ".join(cmd)
- return subprocess.call(cmd, shell=self.shell, env=self.env)
+ return subprocess.call(cmd, shell=self.shell, env=self.env, preexec_fn=default_sigpipe)
def __run(self, args):
"""