| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 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 TEMP_FAILURE_RETRY(close(read_in[0])); | 342 TEMP_FAILURE_RETRY(close(read_in[0])); |
| 342 TEMP_FAILURE_RETRY(close(read_in[1])); | 343 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 TEMP_FAILURE_RETRY(close(read_in[0])); | 352 TEMP_FAILURE_RETRY(close(read_in[0])); |
| 351 TEMP_FAILURE_RETRY(close(read_in[1])); | 353 TEMP_FAILURE_RETRY(close(read_in[1])); |
| 352 TEMP_FAILURE_RETRY(close(read_err[0])); | 354 TEMP_FAILURE_RETRY(close(read_err[0])); |
| 353 TEMP_FAILURE_RETRY(close(read_err[1])); | 355 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 TEMP_FAILURE_RETRY(close(read_in[0])); | 364 TEMP_FAILURE_RETRY(close(read_in[0])); |
| 362 TEMP_FAILURE_RETRY(close(read_in[1])); | 365 TEMP_FAILURE_RETRY(close(read_in[1])); |
| 363 TEMP_FAILURE_RETRY(close(read_err[0])); | 366 TEMP_FAILURE_RETRY(close(read_err[0])); |
| 364 TEMP_FAILURE_RETRY(close(read_err[1])); | 367 TEMP_FAILURE_RETRY(close(read_err[1])); |
| 365 TEMP_FAILURE_RETRY(close(write_out[0])); | 368 TEMP_FAILURE_RETRY(close(write_out[0])); |
| 366 TEMP_FAILURE_RETRY(close(write_out[1])); | 369 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 TEMP_FAILURE_RETRY(close(read_in[0])); | 378 TEMP_FAILURE_RETRY(close(read_in[0])); |
| 379 TEMP_FAILURE_RETRY(close(read_in[1])); | 379 TEMP_FAILURE_RETRY(close(read_in[1])); |
| 380 TEMP_FAILURE_RETRY(close(read_err[0])); | 380 TEMP_FAILURE_RETRY(close(read_err[0])); |
| 381 TEMP_FAILURE_RETRY(close(read_err[1])); | 381 TEMP_FAILURE_RETRY(close(read_err[1])); |
| 382 TEMP_FAILURE_RETRY(close(write_out[0])); | 382 TEMP_FAILURE_RETRY(close(write_out[0])); |
| 383 TEMP_FAILURE_RETRY(close(write_out[1])); | 383 TEMP_FAILURE_RETRY(close(write_out[1])); |
| 384 TEMP_FAILURE_RETRY(close(exec_control[0])); | 384 TEMP_FAILURE_RETRY(close(exec_control[0])); |
| 385 TEMP_FAILURE_RETRY(close(exec_control[1])); | 385 TEMP_FAILURE_RETRY(close(exec_control[1])); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 void Process::TerminateExitCodeHandler() { | 564 void Process::TerminateExitCodeHandler() { |
| 565 ExitCodeHandler::TerminateExitCodeThread(); | 565 ExitCodeHandler::TerminateExitCodeThread(); |
| 566 } | 566 } |
| 567 | 567 |
| 568 | 568 |
| 569 intptr_t Process::CurrentProcessId() { | 569 intptr_t Process::CurrentProcessId() { |
| 570 return static_cast<intptr_t>(getpid()); | 570 return static_cast<intptr_t>(getpid()); |
| 571 } | 571 } |
| 572 | 572 |
| 573 #endif // defined(TARGET_OS_ANDROID) | 573 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |