From d0a89289d5c80480617968dad17ffb258777fd3f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 2 Feb 2017 20:18:20 +0100 Subject: csource: fix parallel mode to wait for subprocesses Currently it lefts some orphaned children, so that ctrl+C does not kill them. Wait for the children. --- csource/csource.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'csource') diff --git a/csource/csource.go b/csource/csource.go index c0da3317b..4311bfc98 100644 --- a/csource/csource.go +++ b/csource/csource.go @@ -89,7 +89,9 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) { fmt.Fprintf(w, "\tfor (i = 0; i < %v; i++) {\n", opts.Procs) fmt.Fprint(w, "\t\tif (fork() == 0) {\n") fmt.Fprintf(w, "\t\t\tsetup_main_process();\n") - fmt.Fprintf(w, "\t\t\tdo_sandbox_%v(i, %v);\n", opts.Sandbox, enableTun) + fmt.Fprintf(w, "\t\t\tint pid = do_sandbox_%v(i, %v);\n", opts.Sandbox, enableTun) + fmt.Fprint(w, "\t\t\tint status = 0;\n") + fmt.Fprint(w, "\t\t\twhile (waitpid(pid, &status, __WALL) != pid) {}\n") fmt.Fprint(w, "\t\t\treturn 0;\n") fmt.Fprint(w, "\t\t}\n") fmt.Fprint(w, "\t}\n") -- cgit mrf-deployment