| 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_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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 *os_error_message); | 327 *os_error_message); |
| 328 return errno; | 328 return errno; |
| 329 } | 329 } |
| 330 | 330 |
| 331 result = TEMP_FAILURE_RETRY(pipe(read_in)); | 331 result = TEMP_FAILURE_RETRY(pipe(read_in)); |
| 332 if (result < 0) { | 332 if (result < 0) { |
| 333 SetChildOsErrorMessage(os_error_message); | 333 SetChildOsErrorMessage(os_error_message); |
| 334 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); | 334 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); |
| 335 return errno; | 335 return errno; |
| 336 } | 336 } |
| 337 FDUtils::SetCloseOnExec(read_in[0]); |
| 337 | 338 |
| 338 result = TEMP_FAILURE_RETRY(pipe(read_err)); | 339 result = TEMP_FAILURE_RETRY(pipe(read_err)); |
| 339 if (result < 0) { | 340 if (result < 0) { |
| 340 SetChildOsErrorMessage(os_error_message); | 341 SetChildOsErrorMessage(os_error_message); |
| 341 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); | 342 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); |
| 342 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); | 343 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); |
| 343 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); | 344 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); |
| 344 return errno; | 345 return errno; |
| 345 } | 346 } |
| 347 FDUtils::SetCloseOnExec(read_err[0]); |
| 346 | 348 |
| 347 result = TEMP_FAILURE_RETRY(pipe(write_out)); | 349 result = TEMP_FAILURE_RETRY(pipe(write_out)); |
| 348 if (result < 0) { | 350 if (result < 0) { |
| 349 SetChildOsErrorMessage(os_error_message); | 351 SetChildOsErrorMessage(os_error_message); |
| 350 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); | 352 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); |
| 351 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); | 353 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); |
| 352 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); | 354 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); |
| 353 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); | 355 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); |
| 354 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); | 356 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); |
| 355 return errno; | 357 return errno; |
| 356 } | 358 } |
| 359 FDUtils::SetCloseOnExec(write_out[1]); |
| 357 | 360 |
| 358 result = TEMP_FAILURE_RETRY(pipe(exec_control)); | 361 result = TEMP_FAILURE_RETRY(pipe(exec_control)); |
| 359 if (result < 0) { | 362 if (result < 0) { |
| 360 SetChildOsErrorMessage(os_error_message); | 363 SetChildOsErrorMessage(os_error_message); |
| 361 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); | 364 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); |
| 362 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); | 365 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); |
| 363 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); | 366 VOID_TEMP_FAILURE_RETRY(close(read_err[0])); |
| 364 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); | 367 VOID_TEMP_FAILURE_RETRY(close(read_err[1])); |
| 365 VOID_TEMP_FAILURE_RETRY(close(write_out[0])); | 368 VOID_TEMP_FAILURE_RETRY(close(write_out[0])); |
| 366 VOID_TEMP_FAILURE_RETRY(close(write_out[1])); | 369 VOID_TEMP_FAILURE_RETRY(close(write_out[1])); |
| 367 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); | 370 Log::PrintErr("Error pipe creation failed: %s\n", *os_error_message); |
| 368 return errno; | 371 return errno; |
| 369 } | 372 } |
| 373 FDUtils::SetCloseOnExec(exec_control[0]); |
| 374 FDUtils::SetCloseOnExec(exec_control[1]); |
| 370 | 375 |
| 371 // Set close on exec on the write file descriptor of the exec control pipe. | |
| 372 result = TEMP_FAILURE_RETRY( | |
| 373 fcntl(exec_control[1], | |
| 374 F_SETFD, | |
| 375 TEMP_FAILURE_RETRY(fcntl(exec_control[1], F_GETFD)) | FD_CLOEXEC)); | |
| 376 if (result < 0) { | 376 if (result < 0) { |
| 377 SetChildOsErrorMessage(os_error_message); | 377 SetChildOsErrorMessage(os_error_message); |
| 378 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); | 378 VOID_TEMP_FAILURE_RETRY(close(read_in[0])); |
| 379 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); | 379 VOID_TEMP_FAILURE_RETRY(close(read_in[1])); |
| 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 VOID_TEMP_FAILURE_RETRY(close(exec_control[0])); | 384 VOID_TEMP_FAILURE_RETRY(close(exec_control[0])); |
| 385 VOID_TEMP_FAILURE_RETRY(close(exec_control[1])); | 385 VOID_TEMP_FAILURE_RETRY(close(exec_control[1])); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 void Process::TerminateExitCodeHandler() { | 558 void Process::TerminateExitCodeHandler() { |
| 559 ExitCodeHandler::TerminateExitCodeThread(); | 559 ExitCodeHandler::TerminateExitCodeThread(); |
| 560 } | 560 } |
| 561 | 561 |
| 562 | 562 |
| 563 intptr_t Process::CurrentProcessId() { | 563 intptr_t Process::CurrentProcessId() { |
| 564 return static_cast<intptr_t>(getpid()); | 564 return static_cast<intptr_t>(getpid()); |
| 565 } | 565 } |
| 566 | 566 |
| 567 #endif // defined(TARGET_OS_MACOS) | 567 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |