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_OPENBSD) |
7 | 7 |
8 #include "bin/process.h" | 8 #include "bin/process.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
11 #include <fcntl.h> // NOLINT | 11 #include <fcntl.h> // NOLINT |
12 #include <poll.h> // NOLINT | 12 #include <poll.h> // NOLINT |
13 #include <stdio.h> // NOLINT | 13 #include <stdio.h> // NOLINT |
14 #include <stdlib.h> // NOLINT | 14 #include <stdlib.h> // NOLINT |
15 #include <string.h> // NOLINT | 15 #include <string.h> // NOLINT |
16 #include <sys/wait.h> // NOLINT | 16 #include <sys/wait.h> // NOLINT |
17 #include <unistd.h> // NOLINT | 17 #include <unistd.h> // NOLINT |
18 | 18 |
19 #include "bin/fdutils.h" | 19 #include "bin/fdutils.h" |
20 #include "bin/lockers.h" | 20 #include "bin/lockers.h" |
21 #include "bin/log.h" | 21 #include "bin/log.h" |
22 #include "bin/thread.h" | 22 #include "bin/thread.h" |
23 | 23 |
24 #include "platform/signal_blocker.h" | 24 #include "platform/signal_blocker.h" |
25 #include "platform/utils.h" | |
26 | 25 |
27 | 26 |
28 extern char **environ; | 27 extern char **environ; |
29 | 28 |
30 | 29 |
31 namespace dart { | 30 namespace dart { |
32 namespace bin { | 31 namespace bin { |
33 | 32 |
34 // ProcessInfo is used to map a process id to the file descriptor for | 33 // ProcessInfo is used to map a process id to the file descriptor for |
35 // the pipe used to communicate the exit code of the process to Dart. | 34 // the pipe used to communicate the exit code of the process to Dart. |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 if (actual_errno == 0) actual_errno = EPERM; | 637 if (actual_errno == 0) actual_errno = EPERM; |
639 SetChildOsErrorMessage(); | 638 SetChildOsErrorMessage(); |
640 CloseAllPipes(); | 639 CloseAllPipes(); |
641 return actual_errno; | 640 return actual_errno; |
642 } | 641 } |
643 | 642 |
644 | 643 |
645 void SetChildOsErrorMessage() { | 644 void SetChildOsErrorMessage() { |
646 const int kBufferSize = 1024; | 645 const int kBufferSize = 1024; |
647 char error_message[kBufferSize]; | 646 char error_message[kBufferSize]; |
648 Utils::StrError(errno, error_message, kBufferSize); | 647 strerror_r(errno, error_message, kBufferSize); |
649 *os_error_message_ = strdup(error_message); | 648 *os_error_message_ = strdup(error_message); |
650 } | 649 } |
651 | 650 |
652 | 651 |
653 void ReportChildError() { | 652 void ReportChildError() { |
654 // In the case of failure in the child process write the errno and | 653 // In the case of failure in the child process write the errno and |
655 // the OS error message to the exec control pipe and exit. | 654 // the OS error message to the exec control pipe and exit. |
656 int child_errno = errno; | 655 int child_errno = errno; |
657 const int kBufferSize = 1024; | 656 const int kBufferSize = 1024; |
658 char os_error_message[kBufferSize]; | 657 char os_error_message[kBufferSize]; |
659 Utils::StrError(errno, os_error_message, kBufferSize); | 658 strerror_r(errno, os_error_message, kBufferSize); |
660 int bytes_written = | 659 int bytes_written = |
661 FDUtils::WriteToBlocking( | 660 FDUtils::WriteToBlocking( |
662 exec_control_[1], &child_errno, sizeof(child_errno)); | 661 exec_control_[1], &child_errno, sizeof(child_errno)); |
663 if (bytes_written == sizeof(child_errno)) { | 662 if (bytes_written == sizeof(child_errno)) { |
664 FDUtils::WriteToBlocking( | 663 FDUtils::WriteToBlocking( |
665 exec_control_[1], os_error_message, strlen(os_error_message) + 1); | 664 exec_control_[1], os_error_message, strlen(os_error_message) + 1); |
666 } | 665 } |
667 VOID_TEMP_FAILURE_RETRY(close(exec_control_[1])); | 666 VOID_TEMP_FAILURE_RETRY(close(exec_control_[1])); |
668 exit(1); | 667 exit(1); |
669 } | 668 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 struct sigaction act; | 997 struct sigaction act; |
999 bzero(&act, sizeof(act)); | 998 bzero(&act, sizeof(act)); |
1000 act.sa_handler = SIG_DFL; | 999 act.sa_handler = SIG_DFL; |
1001 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); | 1000 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); |
1002 } | 1001 } |
1003 } | 1002 } |
1004 | 1003 |
1005 } // namespace bin | 1004 } // namespace bin |
1006 } // namespace dart | 1005 } // namespace dart |
1007 | 1006 |
1008 #endif // defined(TARGET_OS_ANDROID) | 1007 #endif // defined(TARGET_OS_OPENBSD) |
OLD | NEW |