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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
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 "platform/signal_blocker.h" | |
20 #include "bin/fdutils.h" | 19 #include "bin/fdutils.h" |
21 #include "bin/lockers.h" | 20 #include "bin/lockers.h" |
22 #include "bin/log.h" | 21 #include "bin/log.h" |
23 #include "bin/thread.h" | 22 #include "bin/thread.h" |
| 23 #include "platform/signal_blocker.h" |
| 24 #include "platform/utils.h" |
24 | 25 |
25 | 26 |
26 extern char **environ; | 27 extern char **environ; |
27 | 28 |
28 | 29 |
29 namespace dart { | 30 namespace dart { |
30 namespace bin { | 31 namespace bin { |
31 | 32 |
32 // 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 |
33 // 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... |
636 if (actual_errno == 0) actual_errno = EPERM; | 637 if (actual_errno == 0) actual_errno = EPERM; |
637 SetChildOsErrorMessage(); | 638 SetChildOsErrorMessage(); |
638 CloseAllPipes(); | 639 CloseAllPipes(); |
639 return actual_errno; | 640 return actual_errno; |
640 } | 641 } |
641 | 642 |
642 | 643 |
643 void SetChildOsErrorMessage() { | 644 void SetChildOsErrorMessage() { |
644 const int kBufferSize = 1024; | 645 const int kBufferSize = 1024; |
645 char error_buf[kBufferSize]; | 646 char error_buf[kBufferSize]; |
646 *os_error_message_ = strdup(strerror_r(errno, error_buf, kBufferSize)); | 647 *os_error_message_ = strdup(Utils::StrError(errno, error_buf, kBufferSize)); |
647 } | 648 } |
648 | 649 |
649 | 650 |
650 void ReportChildError() { | 651 void ReportChildError() { |
651 // In the case of failure in the child process write the errno and | 652 // In the case of failure in the child process write the errno and |
652 // the OS error message to the exec control pipe and exit. | 653 // the OS error message to the exec control pipe and exit. |
653 int child_errno = errno; | 654 int child_errno = errno; |
654 const int kBufferSize = 1024; | 655 const int kBufferSize = 1024; |
655 char error_buf[kBufferSize]; | 656 char error_buf[kBufferSize]; |
656 char* os_error_message = strerror_r(errno, error_buf, kBufferSize); | 657 char* os_error_message = Utils::StrError(errno, error_buf, kBufferSize); |
657 int bytes_written = | 658 int bytes_written = |
658 FDUtils::WriteToBlocking( | 659 FDUtils::WriteToBlocking( |
659 exec_control_[1], &child_errno, sizeof(child_errno)); | 660 exec_control_[1], &child_errno, sizeof(child_errno)); |
660 if (bytes_written == sizeof(child_errno)) { | 661 if (bytes_written == sizeof(child_errno)) { |
661 FDUtils::WriteToBlocking( | 662 FDUtils::WriteToBlocking( |
662 exec_control_[1], os_error_message, strlen(os_error_message) + 1); | 663 exec_control_[1], os_error_message, strlen(os_error_message) + 1); |
663 } | 664 } |
664 VOID_TEMP_FAILURE_RETRY(close(exec_control_[1])); | 665 VOID_TEMP_FAILURE_RETRY(close(exec_control_[1])); |
665 exit(1); | 666 exit(1); |
666 } | 667 } |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 bzero(&act, sizeof(act)); | 994 bzero(&act, sizeof(act)); |
994 act.sa_handler = SIG_DFL; | 995 act.sa_handler = SIG_DFL; |
995 sigaction(signal, &act, NULL); | 996 sigaction(signal, &act, NULL); |
996 } | 997 } |
997 } | 998 } |
998 | 999 |
999 } // namespace bin | 1000 } // namespace bin |
1000 } // namespace dart | 1001 } // namespace dart |
1001 | 1002 |
1002 #endif // defined(TARGET_OS_LINUX) | 1003 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |