OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2015 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 /* |
| 8 * NaCl Async Signal Support |
| 9 */ |
| 10 |
| 11 #ifndef __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_SIGNAL_H__ |
| 12 #define __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_SIGNAL_H__ 1 |
| 13 |
| 14 #if defined(__cplusplus) |
| 15 extern "C" { |
| 16 #endif |
| 17 |
| 18 struct NaClExceptionContext; |
| 19 typedef void (*nacl_signal_handler_t)(struct NaClExceptionContext *context); |
| 20 |
| 21 /* |
| 22 * Sets the global signal handler. |
| 23 * |
| 24 * NaCl applications can register a single, global signal handler that will be |
| 25 * invoked on the thread that receives the signal. As opposed to POSIX, the |
| 26 * signal mask is not changed upon entering/exiting the handler, so it is |
| 27 * possible for the signal handler to be interrupted by itself, even on the same |
| 28 * thread. Furthermore, the signal handler will run in the same thread in which |
| 29 * the signal is delivered in the same stack. This function is not |
| 30 * async-signal-safe, and should not be used within a signal handler. |
| 31 * @return 0 on success. A positive errno value on error. |
| 32 */ |
| 33 int nacl_signal_set_handler(nacl_signal_handler_t handler); |
| 34 |
| 35 /* |
| 36 * Asynchronously delivers a signal to a thread. |
| 37 * |
| 38 * This function delivers a signal to the thread identified by |tid| within the |
| 39 * same thread group as the caller. This function requires |
| 40 * |nacl_signal_set_handler| to be called first, otherwise it will fail with |
| 41 * ESRCH. |tid| must be a valid thread identifier obtained when creating the |
| 42 * thread, or 0 to refer to the main thread. Using an invalid |tid| will result |
| 43 * in undefined behavior. This function is async-signal-safe, and can be used |
| 44 * within a signal handler. |
| 45 * @return 0 on success. A positive errno value on error. |
| 46 */ |
| 47 int nacl_signal_send_async_signal(uintptr_t tid); |
| 48 |
| 49 #if defined(__cplusplus) |
| 50 } |
| 51 #endif |
| 52 |
| 53 #endif /* __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_SIGNAL_H__ */ |
OLD | NEW |