| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #if defined(FLETCH_TARGET_OS_MACOS) | 5 #if defined(DARTINO_TARGET_OS_MACOS) |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <mach-o/dyld.h> | 8 #include <mach-o/dyld.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| 11 #include <sys/errno.h> | 11 #include <sys/errno.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include "src/shared/assert.h" | 14 #include "src/shared/assert.h" |
| 15 | 15 |
| 16 #include "src/tools/driver/platform.h" | 16 #include "src/tools/driver/platform.h" |
| 17 | 17 |
| 18 #define MAX_SIGNAL SIGUSR2 | 18 #define MAX_SIGNAL SIGUSR2 |
| 19 | 19 |
| 20 namespace fletch { | 20 namespace dartino { |
| 21 | 21 |
| 22 static int signal_pipe[] = {-1, -1}; | 22 static int signal_pipe[] = {-1, -1}; |
| 23 | 23 |
| 24 static void SignalHandler(int signal) { | 24 static void SignalHandler(int signal) { |
| 25 int old_errno = errno; | 25 int old_errno = errno; |
| 26 if (write(signal_pipe[1], &signal, sizeof(signal)) == -1) { | 26 if (write(signal_pipe[1], &signal, sizeof(signal)) == -1) { |
| 27 const char message[] = "write failed in signal handler\n"; | 27 const char message[] = "write failed in signal handler\n"; |
| 28 write(STDERR_FILENO, message, sizeof(message)); | 28 write(STDERR_FILENO, message, sizeof(message)); |
| 29 UNREACHABLE(); | 29 UNREACHABLE(); |
| 30 } | 30 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // WTERMSIG in wait(2). So to forward the signalled exit status to our | 104 // WTERMSIG in wait(2). So to forward the signalled exit status to our |
| 105 // parent process, we send a signal to ourselves. | 105 // parent process, we send a signal to ourselves. |
| 106 signal(-exit_code, SIG_DFL); | 106 signal(-exit_code, SIG_DFL); |
| 107 raise(-exit_code); | 107 raise(-exit_code); |
| 108 } else { | 108 } else { |
| 109 exit(exit_code); | 109 exit(exit_code); |
| 110 } | 110 } |
| 111 UNREACHABLE(); | 111 UNREACHABLE(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace fletch | 114 } // namespace dartino |
| 115 | 115 |
| 116 #endif // defined(FLETCH_TARGET_OS_MACOS) | 116 #endif // defined(DARTINO_TARGET_OS_MACOS) |
| OLD | NEW |