From fab49d91255ef7d265817213c3da7e5f81df97a0 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 21 Nov 2016 10:40:03 +0100 Subject: [PATCH] also join processes terminated by signal --- src/app/proc.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/proc.cpp b/src/app/proc.cpp index c219c72..add16d1 100644 --- a/src/app/proc.cpp +++ b/src/app/proc.cpp @@ -311,11 +311,20 @@ int Process::Impl::Join() { if (result == -1) { throw SysError("error waiting on child process"); } - if (result == pid && WIFEXITED(status)) { + if (result != pid) { + // should in theory only happen with WNOHANG set + continue; + } + if (WIFEXITED(status)) { + // autonomous termination return WEXITSTATUS(status); } - // otherwise, child probably signalled, which we don't care - // about (please don't tell youth welfare), so try again + if (WIFSIGNALED(status)) { + // signalled termination + return WTERMSIG(status); + } + // otherwise, child probably signalled stop/continue, which we + // don't care about (please don't tell youth welfare), so try again } #endif } -- 2.39.2