[issue19575] subprocess.Popen with multiple threads: Redirected stdout/stderr files still open after process close

Bernt Røskar Brenna report at bugs.python.org
Mon Nov 18 13:42:32 CET 2013


Bernt Røskar Brenna added the comment:

And here's a function that does not require pywin32:

def open_noinherit_ctypes(*args, **kwargs):
    HANDLE_FLAG_INHERIT = 1

    import msvcrt
    from ctypes import windll, WinError
    fp = open(*args, **kwargs)
    if not windll.kernel32.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()), HANDLE_FLAG_INHERIT, 0):
        raise WinError()
    return fp

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19575>
_______________________________________


More information about the Python-bugs-list mailing list