From: lostd Date: Mon, 13 Oct 2014 07:22:05 +0000 (+0300) Subject: Properly wait for processes to terminate X-Git-Tag: v1.0~92^2~220 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=955152417fd24026dfd5582068cb50219419b137;p=nnn.git Properly wait for processes to terminate --- diff --git a/noice.c b/noice.c index 54cedef6..0420cc39 100644 --- a/noice.c +++ b/noice.c @@ -427,6 +427,7 @@ begin: char *tmp; regex_t re; struct history *hist; + int status; redraw: nlines = MIN(LINES - 4, n); @@ -560,10 +561,16 @@ nochange: /* Run program */ pid = fork(); - if (pid == 0) + if (pid == 0) { execlp(bin, bin, pathnew, NULL); - else - waitpid(pid, NULL, 0); + _exit(0); + } else { + /* Ignore interruptions */ + while (waitpid(pid, &status, + 0) == -1) + DPRINTF_D(status); + DPRINTF_D(pid); + } initcurses();