From 642c341d265afa4084386883f16a06553b8fa2d9 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 14 Apr 2022 18:18:17 +0200 Subject: [PATCH] Handle waiting on a dead process --- src/common/process.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/process.cpp b/src/common/process.cpp index 47d36b7f..0e8c1f30 100644 --- a/src/common/process.cpp +++ b/src/common/process.cpp @@ -169,8 +169,10 @@ void Process::Handle::terminate() const noexcept { } std::optional Process::Handle::wait() const noexcept { + // This may fail if we've already reaped the process and terminate gets + // called another time, so we won't check the result here int status = 0; - assert(waitpid(pid_, &status, 0) > 0); + waitpid(pid_, &status, 0); if (WIFEXITED(status)) { return WEXITSTATUS(status);