From: Daniel Karbach Date: Mon, 21 Nov 2016 09:40:03 +0000 (+0100) Subject: also join processes terminated by signal X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=fab49d91255ef7d265817213c3da7e5f81df97a0;p=blank.git also join processes terminated by signal --- 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 }