mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
16bbe5baa2
Summary: The CreateProcess API allows inheritable handles to be available in the spawned process by passing a flag to it. What the documentation for this API leave to the imagination is what happens when processes are spawned concurrently in multiple threads and handles are opened and made inheritable while doing this. The answer is obvious but the consequences aren't: they are inherited. When anonymous Pipes are used, one end needs to be inheritable for the spawned process to being able use it, but if one is created concurrently with spawning a process, that other process may have an open handle to that unrelated pipe. And since to detect that a pipe is closed, all handles to the other end needs to be closed, this can lead to never being able to detect that it is closed... This scenario is exactly what is happening in eden when spawning the Mercurial process, and when one of these processes would die, eden would just hang trying to write to the pipe, not knowing that the process was already gone. To unblock eden, all the hg.real processes had to be killed, as this would close all the pipe handles, and then eden would detect that the pipe was closed and re-spawn Mercurial (only for the exact same thing to happen). In order to fix this, we need to tell CreateProcess to only inherit the pipes handles, and nothing else. Reviewed By: wez Differential Revision: D21895537 fbshipit-source-id: 3c84a1d0316b50b5750f554fa20f72f59a718882 |
||
---|---|---|
.. | ||
test | ||
CMakeLists.txt | ||
FileUtils.cpp | ||
FileUtils.h | ||
Guid.h | ||
Handle.h | ||
Pipe.cpp | ||
Pipe.h | ||
RegUtils.cpp | ||
RegUtils.h | ||
StringConv.h | ||
Stub.h | ||
Subprocess.cpp | ||
Subprocess.h | ||
WinError.cpp | ||
WinError.h |