From a9e45e26e6e5a79a5c3320ee4c4dc1206409d4e5 Mon Sep 17 00:00:00 2001 From: Joseph Werle Date: Tue, 28 Nov 2023 17:11:19 +0100 Subject: [PATCH] fix(src/cli/cli.cc): fix signal handling race on exit --- src/cli/cli.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cli/cli.cc b/src/cli/cli.cc index ba5316ecd6..8898714f6c 100644 --- a/src/cli/cli.cc +++ b/src/cli/cli.cc @@ -1000,14 +1000,18 @@ int runApp (const Path& path, const String& args, bool headless) { appPid = appProcess->open(); appProcess->wait(); - auto status = appProcess->status.load(); + std::lock_guard lock(appMutex); - if (status > -1) { - appStatus = status; - } + if (appProcess != nullptr) { + auto status = appProcess->status.load(); - delete appProcess; - appProcess = nullptr; + if (status > -1) { + appStatus = status; + } + + delete appProcess; + appProcess = nullptr; + } log("App result: " + std::to_string(appStatus)); return appStatus;