[Reproducible-commits] [diffoscope] 01/03: Use pass_fds from Popen instead of reimplementing it

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Dec 2 13:17:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository diffoscope.

commit ef62332de70cdfc8772a24436183498761c1340d
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Dec 2 15:12:04 2015 +0200

    Use pass_fds from Popen instead of reimplementing it
    
    Thanks Baptiste Daroussin for the tip!
    
    (I've also been told it's wrong to close random fds on Mac OS X after a fork, as some
    might be required by some tools…)
---
 diffoscope/difference.py | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 0372967..132f471 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -129,14 +129,6 @@ DIFF_CHUNK = 4096
 def run_diff(fd1, fd2, end_nl_q1, end_nl_q2):
     cmd = ['diff', '-au7', '/dev/fd/%d' % fd1, '/dev/fd/%d' % fd2]
     logger.debug('running %s', cmd)
-    def close_fds():
-        fds = [int(fd) for fd in os.listdir('/dev/fd')
-                       if int(fd) not in (1, 2, fd1, fd2)]
-        for fd in fds:
-            try:
-                os.close(fd)
-            except OSError:
-                pass
     if hasattr(os, 'set_inheritable'): # new in Python 3.4
         os.set_inheritable(fd1, True)
         os.set_inheritable(fd2, True)
@@ -144,8 +136,7 @@ def run_diff(fd1, fd2, end_nl_q1, end_nl_q2):
                          stdin=subprocess.PIPE,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT,
-                         preexec_fn=close_fds,
-                         close_fds=False)
+                         pass_fds=(fd1, fd2))
     p.stdin.close()
     os.close(fd1)
     os.close(fd2)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list