util: subprocess close_fds option is unix only
authorPatrick Mezard <pmezard@gmail.com>
Sat, 18 Oct 2008 15:49:15 +0200
changeset 7123 716277f5867e
parent 7122 3cf699e89e48
child 7124 63579aa36c8e
util: subprocess close_fds option is unix only
mercurial/util.py
--- a/mercurial/util.py	Sat Oct 18 14:43:20 2008 +0200
+++ b/mercurial/util.py	Sat Oct 18 15:49:15 2008 +0200
@@ -51,18 +51,22 @@
 
 try:
     import subprocess
+    closefds = os.name == 'posix'
     def popen2(cmd, mode='t', bufsize=-1):
-        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, close_fds=True,
+        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+                             close_fds=closefds,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE)
         return p.stdin, p.stdout
     def popen3(cmd, mode='t', bufsize=-1):
-        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, close_fds=True,
+        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+                             close_fds=closefds,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
         return p.stdin, p.stdout, p.stderr
     def Popen3(cmd, capturestderr=False, bufsize=-1):
         stderr = capturestderr and subprocess.PIPE or None
-        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, close_fds=True,
+        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+                             close_fds=closefds,
                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                              stderr=stderr)
         p.fromchild = p.stdout