From 3e4b08ed095b12675b8865893274c65782720fe6 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 24 Apr 2009 16:51:21 +0200 Subject: restore default signal handlers before subprocess.call Closes: #525411 --- gbp/command_wrappers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gbp/command_wrappers.py') diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 0397a3f..e000af1 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): """ -- cgit v1.2.3