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

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

Issue 23494048: Always wait for child processes when forked, even if the process failed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (program_environment != NULL) { 398 if (program_environment != NULL) {
399 environ = program_environment; 399 environ = program_environment;
400 } 400 }
401 401
402 TEMP_FAILURE_RETRY( 402 TEMP_FAILURE_RETRY(
403 execvp(path, const_cast<char* const*>(program_arguments))); 403 execvp(path, const_cast<char* const*>(program_arguments)));
404 404
405 ReportChildError(exec_control[1]); 405 ReportChildError(exec_control[1]);
406 } 406 }
407 407
408 // Be sure to listen for exit-codes, now we have a child-process.
409 ExitCodeHandler::ProcessStarted();
410
408 // The arguments and environment for the spawned process are not needed 411 // The arguments and environment for the spawned process are not needed
409 // any longer. 412 // any longer.
410 delete[] program_arguments; 413 delete[] program_arguments;
411 delete[] program_environment; 414 delete[] program_environment;
412 415
413 int event_fds[2]; 416 int event_fds[2];
414 result = TEMP_FAILURE_RETRY(pipe(event_fds)); 417 result = TEMP_FAILURE_RETRY(pipe(event_fds));
415 if (result < 0) { 418 if (result < 0) {
416 SetChildOsErrorMessage(os_error_message); 419 SetChildOsErrorMessage(os_error_message);
417 TEMP_FAILURE_RETRY(close(read_in[0])); 420 TEMP_FAILURE_RETRY(close(read_in[0]));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 FDUtils::SetNonBlocking(read_in[0]); 487 FDUtils::SetNonBlocking(read_in[0]);
485 *in = read_in[0]; 488 *in = read_in[0];
486 TEMP_FAILURE_RETRY(close(read_in[1])); 489 TEMP_FAILURE_RETRY(close(read_in[1]));
487 FDUtils::SetNonBlocking(write_out[1]); 490 FDUtils::SetNonBlocking(write_out[1]);
488 *out = write_out[1]; 491 *out = write_out[1];
489 TEMP_FAILURE_RETRY(close(write_out[0])); 492 TEMP_FAILURE_RETRY(close(write_out[0]));
490 FDUtils::SetNonBlocking(read_err[0]); 493 FDUtils::SetNonBlocking(read_err[0]);
491 *err = read_err[0]; 494 *err = read_err[0];
492 TEMP_FAILURE_RETRY(close(read_err[1])); 495 TEMP_FAILURE_RETRY(close(read_err[1]));
493 496
494 // Be sure to listen for exit-codes, now we have a child-process.
495 ExitCodeHandler::ProcessStarted();
496
497 *id = pid; 497 *id = pid;
498 return 0; 498 return 0;
499 } 499 }
500 500
501 501
502 class BufferList: public BufferListBase { 502 class BufferList: public BufferListBase {
503 public: 503 public:
504 bool Read(int fd, intptr_t available) { 504 bool Read(int fd, intptr_t available) {
505 // Read all available bytes. 505 // Read all available bytes.
506 while (available > 0) { 506 while (available > 0) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 627
628 628
629 intptr_t Process::CurrentProcessId() { 629 intptr_t Process::CurrentProcessId() {
630 return static_cast<intptr_t>(getpid()); 630 return static_cast<intptr_t>(getpid());
631 } 631 }
632 632
633 } // namespace bin 633 } // namespace bin
634 } // namespace dart 634 } // namespace dart
635 635
636 #endif // defined(TARGET_OS_LINUX) 636 #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