commit 63d94614fadf26fe058afb1afa9c9b7686efac8f
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Thu Jun 2 11:33:57 2016 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Thu Jun 2 11:33:57 2016 +0200

    [driver] Move wait logic to build()
    
    We need this code in build because we have to wait for all the
    process before moving to compile the next source.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index ca8e69c..5c04947 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -189,6 +189,15 @@ build(char *file)
                spawn(settool(inittool(tool), out));
                in = tool;
        }
+       for (i = 0; i < NR_TOOLS; ++i) {
+               if ((pid = tools[i].pid) == 0)
+                       continue;
+               if (waitpid(pid, &st, 0) < 0)
+                       exit(-1);
+               tools[i].pid = 0;
+               if (!WIFEXITED(st) || WEXITSTATUS(st) != 0)
+                       exit(-1);
+       }
 }
 
 static void
@@ -236,14 +245,5 @@ main(int argc, char *argv[])
 
        build(*argv);
 
-       for (i = 0; i < NR_TOOLS; ++i) {
-               if ((pid = wait(&st)) < 0)
-                       break;
-               if (pid == tools[i].pid)
-                       tools[i].pid = 0;
-               if (!WIFEXITED(st) || WEXITSTATUS(st) != 0)
-                       exit(-1);
-       }
-
        return 0;
 }

Reply via email to