| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "bin/process.h" | 8 #include "bin/process.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (TEMP_FAILURE_RETRY(dup2(read_in[1], STDOUT_FILENO)) == -1) { | 461 if (TEMP_FAILURE_RETRY(dup2(read_in[1], STDOUT_FILENO)) == -1) { |
| 462 ReportChildError(exec_control[1]); | 462 ReportChildError(exec_control[1]); |
| 463 } | 463 } |
| 464 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); | 464 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); |
| 465 | 465 |
| 466 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) { | 466 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) { |
| 467 ReportChildError(exec_control[1]); | 467 ReportChildError(exec_control[1]); |
| 468 } | 468 } |
| 469 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); | 469 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); |
| 470 | 470 |
| 471 if (working_directory != NULL && chdir(working_directory) == -1) { | 471 if (working_directory != NULL && |
| 472 TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) { |
| 472 ReportChildError(exec_control[1]); | 473 ReportChildError(exec_control[1]); |
| 473 } | 474 } |
| 474 | 475 |
| 475 if (program_environment != NULL) { | 476 if (program_environment != NULL) { |
| 476 environ = program_environment; | 477 environ = program_environment; |
| 477 } | 478 } |
| 478 | 479 |
| 479 VOID_TEMP_FAILURE_RETRY( | 480 VOID_TEMP_FAILURE_RETRY( |
| 480 execvp(path, const_cast<char* const*>(program_arguments))); | 481 execvp(path, const_cast<char* const*>(program_arguments))); |
| 481 | 482 |
| 482 ReportChildError(exec_control[1]); | 483 ReportChildError(exec_control[1]); |
| 483 } | 484 } |
| 484 } | 485 } |
| 485 | 486 |
| 486 // Be sure to listen for exit-codes, now we have a child-process. | 487 // Be sure to listen for exit-codes, now we have a child-process. |
| 487 ExitCodeHandler::ProcessStarted(); | 488 ExitCodeHandler::ProcessStarted(); |
| 488 | 489 |
| 489 // The arguments and environment for the spawned process are not needed | 490 // The arguments and environment for the spawned process are not needed |
| 490 // any longer. | 491 // any longer. |
| 491 delete[] program_arguments; | 492 delete[] program_arguments; |
| 492 delete[] program_environment; | 493 delete[] program_environment; |
| 493 | 494 |
| 494 if (!detach) { | 495 if (!detach) { |
| 495 int event_fds[2]; | 496 int event_fds[2]; |
| 496 result = pipe(event_fds); | 497 result = TEMP_FAILURE_RETRY(pipe(event_fds)); |
| 497 if (result < 0) { | 498 if (result < 0) { |
| 498 SetChildOsErrorMessage(os_error_message); | 499 SetChildOsErrorMessage(os_error_message); |
| 499 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); | 500 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); |
| 500 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); | 501 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); |
| 501 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); | 502 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); |
| 502 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); | 503 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); |
| 503 VOID_TEMP_FAILURE_RETRY(close(write_out[0])); | 504 VOID_TEMP_FAILURE_RETRY(close(write_out[0])); |
| 504 VOID_TEMP_FAILURE_RETRY(close(write_out[1])); | 505 VOID_TEMP_FAILURE_RETRY(close(write_out[1])); |
| 505 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); | 506 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); |
| 506 return errno; | 507 return errno; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 bzero(&act, sizeof(act)); | 834 bzero(&act, sizeof(act)); |
| 834 act.sa_handler = SIG_DFL; | 835 act.sa_handler = SIG_DFL; |
| 835 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); | 836 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); |
| 836 } | 837 } |
| 837 } | 838 } |
| 838 | 839 |
| 839 } // namespace bin | 840 } // namespace bin |
| 840 } // namespace dart | 841 } // namespace dart |
| 841 | 842 |
| 842 #endif // defined(TARGET_OS_ANDROID) | 843 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |