diff --git a/pep-0446.txt b/pep-0446.txt index 4738160c2..9c8bde27a 100644 --- a/pep-0446.txt +++ b/pep-0446.txt @@ -27,14 +27,25 @@ The inheritance of file descriptors in child processes can be configured on each file descriptor using a *close-on-exec* flag. By default, the close-on-exec flag is not set. -On Windows, file descriptors are not inherited if the -``bInheritHandles`` parameter of the ``CreateProcess()`` function is -``FALSE``, even if the close-on-exec flag is not set. +On Windows, the close-on-exec flag is ``HANDLE_FLAG_INHERIT``. File +descriptors are not inherited if the ``bInheritHandles`` parameter of +the ``CreateProcess()`` function is ``FALSE``, even if the +``HANDLE_FLAG_INHERIT`` flag is set. If ``bInheritHandles`` is ``TRUE``, +only file descriptors with ``HANDLE_FLAG_INHERIT`` flag set are +inherited, others are not. + +On UNIX, the close-on-exec flag is ``O_CLOEXEC``. File descriptors with +the ``O_CLOEXEC`` flag set are closed at the execution of a new program +(ex: when calling ``execv()``). + +The ``O_CLOEXEC`` flag has no effect on ``fork()``, all file descriptors +are inherited by the child process. Futhermore, most properties file +descriptors are shared between the parent and the child processes, +except file attributes which are duplicated (``O_CLOEXEC`` is the only +file attribute). Setting ``O_CLOEXEC`` flag of a file descriptor in the +child process does not change the ``O_CLOEXEC`` flag of the file +descriptor in the parent process. -On UNIX, file descriptors with the close-and-exec flag set are closed at -the execution of a new program (ex: when calling ``execv()``). The flag -has no effect on ``fork()``, all file descriptors are inherited by the -child process. Issues of the inheritance of file descriptors --------------------------------------------- @@ -62,6 +73,9 @@ operation would block. By default, newly created sockets are blocking. Setting the non-blocking mode requires additional system calls. +On UNIX, the blocking flag is ``O_NONBLOCK``: a pipe and a socket are +non-blocking if the ``O_NONBLOCK`` flag is set. + Setting flags at the creation of the file descriptor ----------------------------------------------------