mercurial/util.py
changeset 7123 716277f5867e
parent 7118 619ebf82cef2
child 7137 0c63b87d9bce
equal deleted inserted replaced
7122:3cf699e89e48 7123:716277f5867e
    49             _sha1 = sha.sha
    49             _sha1 = sha.sha
    50     return _sha1(s)
    50     return _sha1(s)
    51 
    51 
    52 try:
    52 try:
    53     import subprocess
    53     import subprocess
       
    54     closefds = os.name == 'posix'
    54     def popen2(cmd, mode='t', bufsize=-1):
    55     def popen2(cmd, mode='t', bufsize=-1):
    55         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, close_fds=True,
    56         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
       
    57                              close_fds=closefds,
    56                              stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    58                              stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    57         return p.stdin, p.stdout
    59         return p.stdin, p.stdout
    58     def popen3(cmd, mode='t', bufsize=-1):
    60     def popen3(cmd, mode='t', bufsize=-1):
    59         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, close_fds=True,
    61         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
       
    62                              close_fds=closefds,
    60                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    63                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    61                              stderr=subprocess.PIPE)
    64                              stderr=subprocess.PIPE)
    62         return p.stdin, p.stdout, p.stderr
    65         return p.stdin, p.stdout, p.stderr
    63     def Popen3(cmd, capturestderr=False, bufsize=-1):
    66     def Popen3(cmd, capturestderr=False, bufsize=-1):
    64         stderr = capturestderr and subprocess.PIPE or None
    67         stderr = capturestderr and subprocess.PIPE or None
    65         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, close_fds=True,
    68         p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
       
    69                              close_fds=closefds,
    66                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    70                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    67                              stderr=stderr)
    71                              stderr=stderr)
    68         p.fromchild = p.stdout
    72         p.fromchild = p.stdout
    69         p.tochild = p.stdin
    73         p.tochild = p.stdin
    70         p.childerr = p.stderr
    74         p.childerr = p.stderr