]> arthur.barton.de Git - bup.git/blobdiff - main.py
main.py: don't leak a file descriptor.
[bup.git] / main.py
diff --git a/main.py b/main.py
index 941242ef4bbb9f6962c930346f916a1ec8bcfd01..2a5cbae2f969d6c53e8c86ba4be59a94caf9f1bf 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -97,9 +97,11 @@ def force_tty():
 
 if fix_stdout or fix_stderr:
     realf = fix_stderr and 2 or 1
+    drealf = os.dup(realf)  # Popen goes crazy with stdout=2
     n = subprocess.Popen([subpath('newliner')],
-                         stdin=subprocess.PIPE, stdout=os.dup(realf),
+                         stdin=subprocess.PIPE, stdout=drealf,
                          close_fds=True, preexec_fn=force_tty)
+    os.close(drealf)
     outf = fix_stdout and n.stdin.fileno() or None
     errf = fix_stderr and n.stdin.fileno() or None
 else: