mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Windows's _pipe() by default allocates inheritable pipes. However, when a spawn happens, we do not have a possiblility to close the unused pipe ends in the child process. This is a problem. Consider the following situation: The child process only reads from the pipe and the parent process uses only the writable end; the parent even closes the writable end. As it happens, the child at this time usually still waits for input in a read(). But since the child has inherited an open writable end, it does not get EOF and hangs ad infinitum. For this reason, pipe handles must not be inheritable. At the first glance, this is curious, since after all it is the purpose of pipes to be inherited by child processes. However, in all cases where this inheritance is needed for a file descriptor, it is dup2()'d to stdin or stdout anyway, and, lo and behold, Windows's dup2() creates inheritable duplicates.