]> git.localhorst.tv Git - blank.git/commitdiff
also join processes terminated by signal
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 21 Nov 2016 09:40:03 +0000 (10:40 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 21 Nov 2016 09:42:11 +0000 (10:42 +0100)
src/app/proc.cpp

index c219c723effe3050b3e5c52221ce497a88f15610..add16d1787a4779068b6ce36b06be9c9d1d9e194 100644 (file)
@@ -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
 }