| 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/platform.h" | 8 #include "bin/platform.h" |
| 9 | 9 |
| 10 #include <signal.h> // NOLINT | 10 #include <signal.h> // NOLINT |
| 11 #include <string.h> // NOLINT | 11 #include <string.h> // NOLINT |
| 12 #include <unistd.h> // NOLINT | 12 #include <unistd.h> // NOLINT |
| 13 | 13 |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 namespace bin { | 16 namespace bin { |
| 17 | 17 |
| 18 bool Platform::Initialize() { | 18 bool Platform::Initialize() { |
| 19 // Turn off the signal handler for SIGPIPE as it causes the process | 19 // Turn off the signal handler for SIGPIPE as it causes the process |
| 20 // to terminate on writing to a closed pipe. Without the signal | 20 // to terminate on writing to a closed pipe. Without the signal |
| 21 // handler error EPIPE is set instead. | 21 // handler error EPIPE is set instead. |
| 22 struct sigaction act; | 22 struct sigaction act; |
| 23 bzero(&act, sizeof(act)); | 23 bzero(&act, sizeof(act)); |
| 24 act.sa_handler = SIG_IGN; | 24 act.sa_handler = SIG_IGN; |
| 25 if (sigaction(SIGPIPE, &act, 0) != 0) { | 25 if (sigaction(SIGPIPE, &act, 0) != 0) { |
| 26 perror("Setting signal handler failed"); | 26 perror("Setting signal handler failed"); |
| 27 return false; | 27 return false; |
| 28 } | 28 } |
| 29 // Unblock SIGCHLD as waiting on spawned child process depends | |
| 30 // on successful interception of this signal. | |
| 31 sigset_t newset; | |
| 32 sigemptyset(&newset); | |
| 33 sigaddset(&newset, SIGCHLD); | |
| 34 if (sigprocmask(SIG_UNBLOCK, &newset, NULL) != 0) { | |
| 35 perror("Unblocking SIGCHLD signal failed"); | |
| 36 } | |
| 37 return true; | 29 return true; |
| 38 } | 30 } |
| 39 | 31 |
| 40 | 32 |
| 41 int Platform::NumberOfProcessors() { | 33 int Platform::NumberOfProcessors() { |
| 42 return sysconf(_SC_NPROCESSORS_ONLN); | 34 return sysconf(_SC_NPROCESSORS_ONLN); |
| 43 } | 35 } |
| 44 | 36 |
| 45 | 37 |
| 46 const char* Platform::OperatingSystem() { | 38 const char* Platform::OperatingSystem() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 69 | 61 |
| 70 | 62 |
| 71 void Platform::FreeEnvironment(char** env, intptr_t count) { | 63 void Platform::FreeEnvironment(char** env, intptr_t count) { |
| 72 delete[] env; | 64 delete[] env; |
| 73 } | 65 } |
| 74 | 66 |
| 75 } // namespace bin | 67 } // namespace bin |
| 76 } // namespace dart | 68 } // namespace dart |
| 77 | 69 |
| 78 #endif // defined(TARGET_OS_ANDROID) | 70 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |