diff --git a/py/bin/gendoc.py b/py/bin/gendoc.py index 9de4c6a7b..5099454fa 100644 --- a/py/bin/gendoc.py +++ b/py/bin/gendoc.py @@ -15,11 +15,12 @@ import sys sys.path.insert(0, '.') import py -import os +import os, subprocess def sysexec(cmd): print "executing", cmd - os.system(cmd) + p = subprocess.Popen(cmd, shell=True) + os.waitpid(p.pid, 0) if __name__ == '__main__': pydir = py.path.local().join("py") diff --git a/py/execnet/register.py b/py/execnet/register.py index e8577d544..fbb8a0ca6 100644 --- a/py/execnet/register.py +++ b/py/execnet/register.py @@ -1,5 +1,6 @@ import os, inspect, socket +from subprocess import Popen, PIPE import sys from py.magic import autopath ; mypath = autopath() from py.__.misc.warn import APIWARN @@ -56,7 +57,8 @@ class InstallableGateway(gateway.Gateway): class PopenCmdGateway(InstallableGateway): def __init__(self, cmd): - infile, outfile = os.popen2(cmd) + p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True) + infile, outfile = p.stdin, p.stdout self._cmd = cmd io = inputoutput.Popen2IO(infile, outfile) super(PopenCmdGateway, self).__init__(io=io) diff --git a/py/misc/_dist.py b/py/misc/_dist.py index 2117515d7..e83be5a0e 100644 --- a/py/misc/_dist.py +++ b/py/misc/_dist.py @@ -1,5 +1,6 @@ import py import sys, os, re +import subprocess from distutils import sysconfig from distutils import core @@ -147,7 +148,8 @@ def addbindir2path(): win32con.SMTO_ABORTIFHUNG, 5000) # Propagate changes to current command prompt - os.system("set PATH=%s" % path) + p = subprocess.Popen("set PATH=%s" % path, shell=True) + os.waitpid(p.pid, 0) def get_registry_value(reg, key, value_name): k = _winreg.OpenKey(reg, key) diff --git a/py/process/cmdexec.py b/py/process/cmdexec.py index 54094d9fc..45211b39f 100644 --- a/py/process/cmdexec.py +++ b/py/process/cmdexec.py @@ -24,13 +24,13 @@ def posix_exec_cmd(cmd): the error-output from the command. """ __tracebackhide__ = True - import popen2 + from subprocess import Popen, PIPE import errno #print "execing", cmd - child = popen2.Popen3(cmd, 1) - stdin, stdout, stderr = child.tochild, child.fromchild, child.childerr - stdin.close() + child = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, + close_fds=True) + stdin, stdout, stderr = child.stdin, child.stdout, child.stderr # XXX sometimes we get a blocked r.read() call (see below) # although select told us there is something to read.