Allow redeclaration of main process via setup_fork_guards()

This is necessary for the history race condition test to succeed.

(That test is permanently disabled under WSL (as it always fails) so I
didn't catch this on my end.)
This commit is contained in:
Mahmoud Al-Qudsi 2018-12-30 20:21:36 -06:00
parent b4301ff54f
commit 077d656b87

View file

@ -2177,6 +2177,15 @@ bool is_forked_child() {
}
void setup_fork_guards() {
static bool already_initialized = false;
is_forked_proc = false;
if (already_initialized) {
// Just mark this process as main and exit
return;
}
already_initialized = true;
pthread_atfork(nullptr, nullptr, []() {
is_forked_proc = true;
});