sapling/eden/fs/win/utils
Xavier Deguillard 16bbe5baa2 win: only inherit the pipe handles
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
2020-06-10 19:29:18 -07:00
..
test error: remove unecessary newlines 2020-05-27 08:53:24 -07:00
CMakeLists.txt Add header file in CMakeLists 2019-10-25 16:29:17 -07:00
FileUtils.cpp win: improve getFileSha1 to not trigger a stack overflow 2020-05-13 11:44:30 -07:00
FileUtils.h win: change the argument order for writeFile 2020-05-05 18:14:54 -07:00
Guid.h Add template function to convert different string input types 2019-11-18 11:31:17 -08:00
Handle.h Tidy up license headers 2019-10-11 05:28:23 -07:00
Pipe.cpp win: only inherit the pipe handles 2020-06-10 19:29:18 -07:00
Pipe.h win: only inherit the pipe handles 2020-06-10 19:29:18 -07:00
RegUtils.cpp Add template function to convert different string input types 2019-11-18 11:31:17 -08:00
RegUtils.h Add registry key class to interface with the Windows registry 2019-10-14 12:20:42 -07:00
StringConv.h eden: accomodate narrowing warnings on windows 2020-03-26 10:30:21 -07:00
Stub.h mount: unify EdenMount::initialize 2020-05-15 13:14:55 -07:00
Subprocess.cpp win: only inherit the pipe handles 2020-06-10 19:29:18 -07:00
Subprocess.h Tidy up license headers 2019-10-11 05:28:23 -07:00
WinError.cpp error: remove unecessary newlines 2020-05-27 08:53:24 -07:00
WinError.h Tidy up license headers 2019-10-11 05:28:23 -07:00