]> Sergey Matveev's repositories - nnn.git/commitdiff
Properly wait for processes to terminate
authorlostd <lostd@2f30.org>
Mon, 13 Oct 2014 07:22:05 +0000 (10:22 +0300)
committerlostd <lostd@2f30.org>
Mon, 13 Oct 2014 07:22:05 +0000 (10:22 +0300)
noice.c

diff --git a/noice.c b/noice.c
index 54cedef6f7cfce72c21aa418ec9fde7c74bb50d6..0420cc39c779b8c35a47d66ce13ced786272614f 100644 (file)
--- 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();