diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-02-02 20:18:20 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-02-02 20:23:40 +0100 |
| commit | d0a89289d5c80480617968dad17ffb258777fd3f (patch) | |
| tree | 2e01671028dd95cda37bfcc07da9ab6df8ecf595 /csource | |
| parent | 820679df30c6a321d08909e3eba94d1dd53b20d8 (diff) | |
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.
Diffstat (limited to 'csource')
| -rw-r--r-- | csource/csource.go | 4 |
1 files changed, 3 insertions, 1 deletions
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") |
