Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Side by Side Diff: runtime/bin/process_linux.cc

Issue 882093002: Align process implementation and fix bugs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (TEMP_FAILURE_RETRY(dup2(read_in[1], STDOUT_FILENO)) == -1) { 459 if (TEMP_FAILURE_RETRY(dup2(read_in[1], STDOUT_FILENO)) == -1) {
460 ReportChildError(exec_control[1]); 460 ReportChildError(exec_control[1]);
461 } 461 }
462 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); 462 VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
463 463
464 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) { 464 if (TEMP_FAILURE_RETRY(dup2(read_err[1], STDERR_FILENO)) == -1) {
465 ReportChildError(exec_control[1]); 465 ReportChildError(exec_control[1]);
466 } 466 }
467 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); 467 VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
468 468
469 if (working_directory != NULL && chdir(working_directory) == -1) { 469 if (working_directory != NULL &&
470 TEMP_FAILURE_RETRY(chdir(working_directory)) == -1) {
470 ReportChildError(exec_control[1]); 471 ReportChildError(exec_control[1]);
471 } 472 }
472 473
473 if (program_environment != NULL) { 474 if (program_environment != NULL) {
474 environ = program_environment; 475 environ = program_environment;
475 } 476 }
476 477
477 VOID_TEMP_FAILURE_RETRY( 478 VOID_TEMP_FAILURE_RETRY(
478 execvp(path, const_cast<char* const*>(program_arguments))); 479 execvp(path, const_cast<char* const*>(program_arguments)));
479 480
480 ReportChildError(exec_control[1]); 481 ReportChildError(exec_control[1]);
481 } 482 }
482 } 483 }
483 484
484 // Be sure to listen for exit-codes, now we have a child-process. 485 // Be sure to listen for exit-codes, now we have a child-process.
485 ExitCodeHandler::ProcessStarted(); 486 ExitCodeHandler::ProcessStarted();
486 487
487 // The arguments and environment for the spawned process are not needed 488 // The arguments and environment for the spawned process are not needed
488 // any longer. 489 // any longer.
489 delete[] program_arguments; 490 delete[] program_arguments;
490 delete[] program_environment; 491 delete[] program_environment;
491 492
492 if (!detach) { 493 if (!detach) {
493 int event_fds[2]; 494 int event_fds[2];
494 result = pipe(event_fds); 495 result = TEMP_FAILURE_RETRY(pipe(event_fds));
495 if (result < 0) { 496 if (result < 0) {
496 SetChildOsErrorMessage(os_error_message); 497 SetChildOsErrorMessage(os_error_message);
497 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); 498 VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
498 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); 499 VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
499 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); 500 VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
500 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); 501 VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
501 VOID_TEMP_FAILURE_RETRY(close(write_out[0])); 502 VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
502 VOID_TEMP_FAILURE_RETRY(close(write_out[1])); 503 VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
503 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); 504 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message);
504 return errno; 505 return errno;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 intptr_t exit_code = exit_code_data.ints[0]; 705 intptr_t exit_code = exit_code_data.ints[0];
705 intptr_t negative = exit_code_data.ints[1]; 706 intptr_t negative = exit_code_data.ints[1];
706 if (negative) exit_code = -exit_code; 707 if (negative) exit_code = -exit_code;
707 result->set_exit_code(exit_code); 708 result->set_exit_code(exit_code);
708 709
709 return true; 710 return true;
710 } 711 }
711 712
712 713
713 bool Process::Kill(intptr_t id, int signal) { 714 bool Process::Kill(intptr_t id, int signal) {
714 return kill(id, signal) != -1; 715 return (TEMP_FAILURE_RETRY(kill(id, signal)) != -1);
715 } 716 }
716 717
717 718
718 void Process::TerminateExitCodeHandler() { 719 void Process::TerminateExitCodeHandler() {
719 ExitCodeHandler::TerminateExitCodeThread(); 720 ExitCodeHandler::TerminateExitCodeThread();
720 } 721 }
721 722
722 723
723 intptr_t Process::CurrentProcessId() { 724 intptr_t Process::CurrentProcessId() {
724 return static_cast<intptr_t>(getpid()); 725 return static_cast<intptr_t>(getpid());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 bzero(&act, sizeof(act)); 829 bzero(&act, sizeof(act));
829 act.sa_handler = SIG_DFL; 830 act.sa_handler = SIG_DFL;
830 sigaction(signal, &act, NULL); 831 sigaction(signal, &act, NULL);
831 } 832 }
832 } 833 }
833 834
834 } // namespace bin 835 } // namespace bin
835 } // namespace dart 836 } // namespace dart
836 837
837 #endif // defined(TARGET_OS_LINUX) 838 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698