Handle waiting on a dead process

This commit is contained in:
Robbert van der Helm
2022-04-14 18:18:17 +02:00
parent b6e63ea0d5
commit 642c341d26
+3 -1
View File
@@ -169,8 +169,10 @@ void Process::Handle::terminate() const noexcept {
}
std::optional<int> 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);