diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-02-27 14:46:32 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-02-27 14:46:32 +0100 |
| commit | 2fd478e0acd6a52144fe78f08995ef1e4ab78776 (patch) | |
| tree | 4896a1232759313cbf88a129bd76b0ffbbea7062 /executor/executor.cc | |
| parent | a460a8a08280201c1f728c7939e0751cbb6b87cc (diff) | |
executor: support wrapping executor with an external sandbox process
If an external sandbox process wraps executor, the out pipe will be closed
before the sandbox process exits this will make ipc package kill the sandbox.
As the result sandbox process will exit with exit status 9 instead of the executor
exit status (notably kRetryStatus). Consequently, ipc will treat it as hard
failure rather than a temporal failure. So we duplicate the exit status on the pipe.
Diffstat (limited to 'executor/executor.cc')
| -rw-r--r-- | executor/executor.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/executor/executor.cc b/executor/executor.cc index 7b224e334..1731fb4e3 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -194,6 +194,16 @@ int main(int argc, char** argv) while (waitpid(-1, &status, __WALL) != pid) { } status = WEXITSTATUS(status); + // If an external sandbox process wraps executor, the out pipe will be closed + // before the sandbox process exits this will make ipc package kill the sandbox. + // As the result sandbox process will exit with exit status 9 instead of the executor + // exit status (notably kRetryStatus). Consequently, ipc will treat it as hard + // failure rather than a temporal failure. So we duplicate the exit status on the pipe. + char tmp = status; + if (write(kOutPipeFd, &tmp, 1)) { + // Not much we can do, but gcc wants us to check the return value. + } + errno = 0; if (status == kFailStatus) fail("loop failed"); if (status == kErrorStatus) |
