in tools/common/process.cc [76:88]
explicit PosixSpawnIORedirector(int stderr_pipe[], bool stdoutToStderr) {
memcpy(stderr_pipe_, stderr_pipe, sizeof(int) * 2);
posix_spawn_file_actions_init(&file_actions_);
posix_spawn_file_actions_addclose(&file_actions_, stderr_pipe_[0]);
if (stdoutToStderr) {
posix_spawn_file_actions_adddup2(&file_actions_, stderr_pipe_[1],
STDOUT_FILENO);
}
posix_spawn_file_actions_adddup2(&file_actions_, stderr_pipe_[1],
STDERR_FILENO);
posix_spawn_file_actions_addclose(&file_actions_, stderr_pipe_[1]);
}