diff --git a/pep-0446.txt b/pep-0446.txt index eb4eb94f7..3c5efa332 100644 --- a/pep-0446.txt +++ b/pep-0446.txt @@ -318,29 +318,31 @@ child process. On Windows, the ``subprocess`` closes all handles and file descriptors in the child process by default. If at least one standard stream (stdin, stdout or stderr) is replaced (ex: redirected into a pipe), all -inheritable handles are inherited in the child process. +inheritable handles and file descriptors 0, 1 and 2 are inherited in the +child process. -All inheritable file descriptors are inherited by the child process -using the functions of the ``os.execv*()`` and ``os.spawn*()`` families. +Using the functions of the ``os.execv*()`` and ``os.spawn*()`` families, +all inheritable handles and all inheritable file descriptors are +inherited by the child process. On UNIX, the ``multiprocessing`` module uses ``os.fork()`` and so all file descriptors are inherited by child processes. -On Windows, all inheritable handles are inherited by the child process -using the ``multiprocessing`` module, all file descriptors except -standard streams are closed. +On Windows, all inheritable handles and file descriptors 0, 1 and 2 are +inherited by the child process using the ``multiprocessing`` module, all +file descriptors except standard streams are closed. Summary: -=========================== ============= ================== ============= -Module FD on UNIX Handles on Windows FD on Windows -=========================== ============= ================== ============= -subprocess, default STD, pass_fds none STD -subprocess, replace stdout STD, pass_fds all STD -subprocess, close_fds=False all all STD -multiprocessing all all STD -os.execv(), os.spawn() all all all -=========================== ============= ================== ============= +=========================== ================ ================== ============= +Module FD on UNIX Handles on Windows FD on Windows +=========================== ================ ================== ============= +subprocess, default STD, pass_fds none STD +subprocess, replace stdout STD, pass_fds all STD +subprocess, close_fds=False all all STD +multiprocessing (not applicable) all STD +os.execv(), os.spawn() all all all +=========================== ================ ================== ============= Legend: @@ -351,6 +353,8 @@ Legend: inherited in the child process * "pass_fds": file descriptors of the *pass_fds* parameter of the subprocess are inherited +* "(not applicable)": on UNIX, the multiprocessing uses ``fork()``, + so this case is not concerned by this PEP. Performances of Closing All File Descriptors