base-linux: avoid global ctor in wait_for_exit

This patch replaces the global '_wait_for_exit_sem' object by a local
static variable, which does not rely on the global ctors. It thereby
fixes the fault_detection test after the removal of the global ctors
execution from core ("base: remove component.cc from core").

Issue #4784
This commit is contained in:
Norman Feske 2023-06-28 17:06:51 +02:00
parent 1a7ff195d9
commit 6e03d731a2

View File

@ -69,20 +69,26 @@ class Pipe_semaphore
}; };
static Pipe_semaphore _wait_for_exit_sem; /* wakeup of '_wait_for_exit' */ static Pipe_semaphore &_wait_for_exit_sem()
static bool _do_exit = false; /* exit condition */ {
static Pipe_semaphore inst { };
return inst;
}
static bool _do_exit = false; /* exit condition */
static void sigint_handler(int) static void sigint_handler(int)
{ {
_do_exit = true; _do_exit = true;
_wait_for_exit_sem.up(); _wait_for_exit_sem().up();
} }
static void sigchld_handler(int) static void sigchld_handler(int)
{ {
_wait_for_exit_sem.up(); _wait_for_exit_sem().up();
} }
@ -125,7 +131,7 @@ void Core::Platform::wait_for_exit()
/* /*
* Block until a signal occurs. * Block until a signal occurs.
*/ */
_wait_for_exit_sem.down(); _wait_for_exit_sem().down();
/* /*
* Each time, the '_wait_for_exit_sem' gets unlocked, we could have * Each time, the '_wait_for_exit_sem' gets unlocked, we could have