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

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

Issue 1076093004: Make all of stdout/stderr/stdin pipes close-on-exec when spawing child processes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« runtime/bin/process_linux.cc ('K') | « 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 <crt_externs.h> // NOLINT 10 #include <crt_externs.h> // NOLINT
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 FDUtils::SetCloseOnExec(exec_control_[0]); 385 FDUtils::SetCloseOnExec(exec_control_[0]);
386 FDUtils::SetCloseOnExec(exec_control_[1]); 386 FDUtils::SetCloseOnExec(exec_control_[1]);
387 387
388 // For a detached process the pipe to connect stdout is still used for 388 // For a detached process the pipe to connect stdout is still used for
389 // signaling when to do the first fork. 389 // signaling when to do the first fork.
390 result = TEMP_FAILURE_RETRY(pipe(read_in_)); 390 result = TEMP_FAILURE_RETRY(pipe(read_in_));
391 if (result < 0) { 391 if (result < 0) {
392 return CleanupAndReturnError(); 392 return CleanupAndReturnError();
393 } 393 }
394 FDUtils::SetCloseOnExec(read_in_[0]); 394 FDUtils::SetCloseOnExec(read_in_[0]);
395 FDUtils::SetCloseOnExec(read_in_[1]);
395 396
396 // For detached processes the pipe to connect stderr and stdin are not used. 397 // For detached processes the pipe to connect stderr and stdin are not used.
397 if (mode_ != kDetached) { 398 if (mode_ != kDetached) {
398 result = TEMP_FAILURE_RETRY(pipe(read_err_)); 399 result = TEMP_FAILURE_RETRY(pipe(read_err_));
399 if (result < 0) { 400 if (result < 0) {
400 return CleanupAndReturnError(); 401 return CleanupAndReturnError();
401 } 402 }
402 FDUtils::SetCloseOnExec(read_err_[0]); 403 FDUtils::SetCloseOnExec(read_err_[0]);
404 FDUtils::SetCloseOnExec(read_err_[1]);
403 405
404 result = TEMP_FAILURE_RETRY(pipe(write_out_)); 406 result = TEMP_FAILURE_RETRY(pipe(write_out_));
405 if (result < 0) { 407 if (result < 0) {
406 return CleanupAndReturnError(); 408 return CleanupAndReturnError();
407 } 409 }
410 FDUtils::SetCloseOnExec(write_out_[0]);
408 FDUtils::SetCloseOnExec(write_out_[1]); 411 FDUtils::SetCloseOnExec(write_out_[1]);
409 } 412 }
410 413
411 return 0; 414 return 0;
412 } 415 }
413 416
414 417
415 void NewProcess() { 418 void NewProcess() {
416 // Wait for parent process before setting up the child process. 419 // Wait for parent process before setting up the child process.
417 char msg; 420 char msg;
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 bzero(&act, sizeof(act)); 1066 bzero(&act, sizeof(act));
1064 act.sa_handler = SIG_DFL; 1067 act.sa_handler = SIG_DFL;
1065 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); 1068 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL));
1066 } 1069 }
1067 } 1070 }
1068 1071
1069 } // namespace bin 1072 } // namespace bin
1070 } // namespace dart 1073 } // namespace dart
1071 1074
1072 #endif // defined(TARGET_OS_MACOS) 1075 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« runtime/bin/process_linux.cc ('K') | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698