From 077d656b87abf6db4d47faf6449a377ebe3ee56a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 30 Dec 2018 20:21:36 -0600 Subject: [PATCH] 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.) --- src/common.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common.cpp b/src/common.cpp index 9362c69b2..94367bdac 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -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; });