| Index: runtime/bin/process_linux.cc
|
| diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc
|
| index 838dc27a75b7aa23aff65aa67dddc2992a2468c6..6f989c4031421a5c339f0553f4994d7f50e95321 100644
|
| --- a/runtime/bin/process_linux.cc
|
| +++ b/runtime/bin/process_linux.cc
|
| @@ -478,26 +478,6 @@ int Process::Start(const char* path,
|
| delete[] program_arguments;
|
| delete[] program_environment;
|
|
|
| - int event_fds[2];
|
| - result = TEMP_FAILURE_RETRY(pipe(event_fds));
|
| - if (result < 0) {
|
| - SetChildOsErrorMessage(os_error_message);
|
| - TEMP_FAILURE_RETRY(close(read_in[0]));
|
| - TEMP_FAILURE_RETRY(close(read_in[1]));
|
| - TEMP_FAILURE_RETRY(close(read_err[0]));
|
| - TEMP_FAILURE_RETRY(close(read_err[1]));
|
| - TEMP_FAILURE_RETRY(close(write_out[0]));
|
| - TEMP_FAILURE_RETRY(close(write_out[1]));
|
| - Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
|
| - return errno;
|
| - }
|
| - FDUtils::SetCloseOnExec(event_fds[0]);
|
| - FDUtils::SetCloseOnExec(event_fds[1]);
|
| -
|
| - ProcessInfoList::AddProcess(pid, event_fds[1]);
|
| - *exit_event = event_fds[0];
|
| - FDUtils::SetNonBlocking(event_fds[0]);
|
| -
|
| // Notify child process to start.
|
| char msg = '1';
|
| result = FDUtils::WriteToBlocking(read_in[1], &msg, sizeof(msg));
|
| @@ -551,6 +531,28 @@ int Process::Start(const char* path,
|
| *err = read_err[0];
|
| TEMP_FAILURE_RETRY(close(read_err[1]));
|
|
|
| + // Everything went well, so we can listen for the exitcode of our child
|
| + // process.
|
| + int event_fds[2];
|
| + result = TEMP_FAILURE_RETRY(pipe(event_fds));
|
| + if (result < 0) {
|
| + SetChildOsErrorMessage(os_error_message);
|
| + TEMP_FAILURE_RETRY(close(read_in[0]));
|
| + TEMP_FAILURE_RETRY(close(read_in[1]));
|
| + TEMP_FAILURE_RETRY(close(read_err[0]));
|
| + TEMP_FAILURE_RETRY(close(read_err[1]));
|
| + TEMP_FAILURE_RETRY(close(write_out[0]));
|
| + TEMP_FAILURE_RETRY(close(write_out[1]));
|
| + Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
|
| + return errno;
|
| + }
|
| + FDUtils::SetCloseOnExec(event_fds[0]);
|
| + FDUtils::SetCloseOnExec(event_fds[1]);
|
| +
|
| + ProcessInfoList::AddProcess(pid, event_fds[1]);
|
| + *exit_event = event_fds[0];
|
| + FDUtils::SetNonBlocking(event_fds[0]);
|
| +
|
| *id = pid;
|
| return 0;
|
| }
|
|
|