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

Side by Side Diff: runtime/bin/process_macos.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_linux.cc ('k') | no next file » | 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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 pid = TEMP_FAILURE_RETRY(fork()); 371 pid = TEMP_FAILURE_RETRY(fork());
372 if (pid < 0) { 372 if (pid < 0) {
373 SetChildOsErrorMessage(os_error_message); 373 SetChildOsErrorMessage(os_error_message);
374 delete[] program_arguments; 374 delete[] program_arguments;
375 VOID_TEMP_FAILURE_RETRY(close(exec_control[0])); 375 VOID_TEMP_FAILURE_RETRY(close(exec_control[0]));
376 VOID_TEMP_FAILURE_RETRY(close(exec_control[1])); 376 VOID_TEMP_FAILURE_RETRY(close(exec_control[1]));
377 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); 377 VOID_TEMP_FAILURE_RETRY(close(read_in[0]));
378 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); 378 VOID_TEMP_FAILURE_RETRY(close(read_in[1]));
379 if (detach) { 379 if (!detach) {
380 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); 380 VOID_TEMP_FAILURE_RETRY(close(read_err[0]));
381 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); 381 VOID_TEMP_FAILURE_RETRY(close(read_err[1]));
382 VOID_TEMP_FAILURE_RETRY(close(write_out[0])); 382 VOID_TEMP_FAILURE_RETRY(close(write_out[0]));
383 VOID_TEMP_FAILURE_RETRY(close(write_out[1])); 383 VOID_TEMP_FAILURE_RETRY(close(write_out[1]));
384 } 384 }
385 return errno; 385 return errno;
386 } else if (pid == 0) { 386 } else if (pid == 0) {
387 // Wait for parent process before setting up the child process. 387 // Wait for parent process before setting up the child process.
388 char msg; 388 char msg;
389 int bytes_read = FDUtils::ReadFromBlocking(read_in[0], &msg, sizeof(msg)); 389 int bytes_read = FDUtils::ReadFromBlocking(read_in[0], &msg, sizeof(msg));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 FDUtils::SetNonBlocking(event_fds[0]); 514 FDUtils::SetNonBlocking(event_fds[0]);
515 } 515 }
516 516
517 // Notify child process to start. 517 // Notify child process to start.
518 char msg = '1'; 518 char msg = '1';
519 result = FDUtils::WriteToBlocking(read_in[1], &msg, sizeof(msg)); 519 result = FDUtils::WriteToBlocking(read_in[1], &msg, sizeof(msg));
520 if (result != sizeof(msg)) { 520 if (result != sizeof(msg)) {
521 perror("Failed sending notification message"); 521 perror("Failed sending notification message");
522 } 522 }
523 523
524 // Read exec result from child. If no data is returned the exec was
525 // successful and the exec call closed the pipe. Otherwise the errno
526 // is written to the pipe.
527 VOID_TEMP_FAILURE_RETRY(close(exec_control[1])); 524 VOID_TEMP_FAILURE_RETRY(close(exec_control[1]));
528 bool failed = false; 525 bool failed = false;
529 int child_errno; 526 int child_errno;
530 int bytes_read = -1; 527 int bytes_read = -1;
531 ASSERT(sizeof(child_errno) == sizeof(errno)); 528 ASSERT(sizeof(child_errno) == sizeof(errno));
532 if (!detach) { 529 if (!detach) {
533 // Read exec result from child. If no data is returned the exec was 530 // Read exec result from child. If no data is returned the exec was
534 // successful and the exec call closed the pipe. Otherwise the errno 531 // successful and the exec call closed the pipe. Otherwise the errno
535 // is written to the pipe. 532 // is written to the pipe.
536 bytes_read = 533 bytes_read =
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 bzero(&act, sizeof(act)); 882 bzero(&act, sizeof(act));
886 act.sa_handler = SIG_DFL; 883 act.sa_handler = SIG_DFL;
887 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); 884 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL));
888 } 885 }
889 } 886 }
890 887
891 } // namespace bin 888 } // namespace bin
892 } // namespace dart 889 } // namespace dart
893 890
894 #endif // defined(TARGET_OS_MACOS) 891 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698