X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=blobdiff_plain;f=lib%2Fbup%2Fhelpers.py;h=cfbdff49692bda777f82547f7dbcffa8030642fe;hp=a5c5165bc5d92bd3274e755886a1f055c46d87a2;hb=3f15a783afa7a62c633cc076e88a5d22731ebd8d;hpb=b26eaeb08c3c497e9b65122f676bb5f7ef495d21 diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index a5c5165..cfbdff4 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -317,14 +317,16 @@ def exo(cmd, stderr=None, shell=False, check=True, - preexec_fn=None): + preexec_fn=None, + close_fds=True): if input: assert stdin in (None, PIPE) stdin = PIPE p = Popen(cmd, stdin=stdin, stdout=PIPE, stderr=stderr, shell=shell, - preexec_fn=preexec_fn) + preexec_fn=preexec_fn, + close_fds=close_fds) out, err = p.communicate(input) if check and p.returncode != 0: raise Exception('subprocess %r failed with status %d%s' @@ -334,13 +336,7 @@ def exo(cmd, def readpipe(argv, preexec_fn=None, shell=False): """Run a subprocess and return its output.""" - p = subprocess.Popen(argv, stdout=subprocess.PIPE, preexec_fn=preexec_fn, - shell=shell) - out, err = p.communicate() - if p.returncode != 0: - raise Exception('subprocess %r failed with status %d' - % (b' '.join(argv), p.returncode)) - return out + return exo(argv, preexec_fn=preexec_fn, shell=shell)[0] def _argmax_base(command):