Move subprocReap to the front of the waiting loop
authorJagger <robert@swiecki.net>
Fri, 4 Mar 2016 01:19:52 +0000 (02:19 +0100)
committerJagger <robert@swiecki.net>
Fri, 4 Mar 2016 01:19:52 +0000 (02:19 +0100)
nsjail.c

index c346d631c4fa4c5d7d7168bdb6f1fe58688268c9..6dbfc0c727f8d61abef6f772f9dda6c47579c391 100644 (file)
--- a/nsjail.c
+++ b/nsjail.c
@@ -136,14 +136,16 @@ static void nsjailListenMode(struct nsjconf_t *nsjconf)
 
 static int nsjailStandaloneMode(struct nsjconf_t *nsjconf)
 {
-       int child_status = 0;
        subprocRunChild(nsjconf, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO);
        for (;;) {
+               int child_status = subprocReap(nsjconf);
+
                if (subprocCount(nsjconf) == 0) {
                        if (nsjconf->mode == MODE_STANDALONE_ONCE) {
                                return child_status;
                        }
                        subprocRunChild(nsjconf, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO);
+                       continue;
                }
                if (nsjailShowProc == true) {
                        nsjailShowProc = false;
@@ -154,11 +156,10 @@ static int nsjailStandaloneMode(struct nsjconf_t *nsjconf)
                        logStop(nsjailSigFatal);
                        return -1;
                }
+
                pause();
-               child_status = subprocReap(nsjconf);
        }
        // not reached
-       return child_status;
 }
 
 int main(int argc, char *argv[])