]> granicus.if.org Git - python/commitdiff
Use os.closerange() in popen2.
authorGeorg Brandl <georg@python.org>
Sat, 23 Feb 2008 22:09:24 +0000 (22:09 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 23 Feb 2008 22:09:24 +0000 (22:09 +0000)
Lib/popen2.py

index dbd6533be6659f55c6d87ab5c1c69e8cde8cc3b8..cb769f886274833bda96938269648a0da742e5a5 100644 (file)
@@ -82,11 +82,7 @@ class Popen3:
     def _run_child(self, cmd):
         if isinstance(cmd, basestring):
             cmd = ['/bin/sh', '-c', cmd]
-        for i in xrange(3, MAXFD):
-            try:
-                os.close(i)
-            except OSError:
-                pass
+        os.closerange(3, MAXFD)
         try:
             os.execvp(cmd[0], cmd)
         finally: