From: Torsten Werner Date: Sat, 2 Apr 2011 08:38:43 +0000 (+0200) Subject: Install default SIGPIPE handler before calling dpkg-deb. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=154f11d09071db32cfbf6451b8f059702856421d;p=dak Install default SIGPIPE handler before calling dpkg-deb. Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index d39f8c58..5c987bdc 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -39,6 +39,7 @@ import re import psycopg2 import traceback import commands +import signal try: # python >= 2.6 @@ -487,6 +488,11 @@ __all__.append('BinContents') ################################################################################ +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) + class DBBinary(ORMObject): def __init__(self, package = None, source = None, version = None, \ maintainer = None, architecture = None, poolfile = None, \ @@ -525,7 +531,8 @@ class DBBinary(ORMObject): package does not contain any regular file. ''' fullpath = self.poolfile.fullpath - dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE) + dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE, + preexec_fn = subprocess_setup) tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|') for member in tar.getmembers(): if not member.isdir():