From 6e03d731a2927680c9189ba1d9a0846dd664f13e Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 28 Jun 2023 17:06:51 +0200 Subject: [PATCH] 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 --- repos/base-linux/src/core/platform.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/repos/base-linux/src/core/platform.cc b/repos/base-linux/src/core/platform.cc index 25352c972d..12c7849a1b 100644 --- a/repos/base-linux/src/core/platform.cc +++ b/repos/base-linux/src/core/platform.cc @@ -69,20 +69,26 @@ class Pipe_semaphore }; -static Pipe_semaphore _wait_for_exit_sem; /* wakeup of '_wait_for_exit' */ -static bool _do_exit = false; /* exit condition */ +static Pipe_semaphore &_wait_for_exit_sem() +{ + static Pipe_semaphore inst { }; + return inst; +} + + +static bool _do_exit = false; /* exit condition */ static void sigint_handler(int) { _do_exit = true; - _wait_for_exit_sem.up(); + _wait_for_exit_sem().up(); } 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. */ - _wait_for_exit_sem.down(); + _wait_for_exit_sem().down(); /* * Each time, the '_wait_for_exit_sem' gets unlocked, we could have