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