From 6fc00951afcaeea56125f52e33c63c360ae6072d Mon Sep 17 00:00:00 2001 From: Jagger Date: Fri, 4 Mar 2016 02:19:52 +0100 Subject: [PATCH] Move subprocReap to the front of the waiting loop --- nsjail.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nsjail.c b/nsjail.c index c346d63..6dbfc0c 100644 --- 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[])