Index: src/include/nacl/nacl_signal.h |
diff --git a/src/include/nacl/nacl_signal.h b/src/include/nacl/nacl_signal.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0e285c806181e031f83590dd4c0bac8ad057e722 |
--- /dev/null |
+++ b/src/include/nacl/nacl_signal.h |
@@ -0,0 +1,53 @@ |
+/* |
+ * Copyright (c) 2015 The Native Client Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+/* |
+ * NaCl Async Signal Support |
+ */ |
+ |
+#ifndef __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_SIGNAL_H__ |
+#define __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_SIGNAL_H__ 1 |
+ |
+#if defined(__cplusplus) |
+extern "C" { |
+#endif |
+ |
+struct NaClExceptionContext; |
+typedef void (*nacl_signal_handler_t)(struct NaClExceptionContext *context); |
+ |
+/* |
+ * Sets the global signal handler. |
+ * |
+ * NaCl applications can register a single, global signal handler that will be |
+ * invoked on the thread that receives the signal. As opposed to POSIX, the |
+ * signal mask is not changed upon entering/exiting the handler, so it is |
+ * possible for the signal handler to be interrupted by itself, even on the same |
+ * thread. Furthermore, the signal handler will run in the same thread in which |
+ * the signal is delivered in the same stack. This function is not |
+ * async-signal-safe, and should not be used within a signal handler. |
+ * @return 0 on success. A positive errno value on error. |
+ */ |
+int nacl_signal_set_handler(nacl_signal_handler_t handler); |
+ |
+/* |
+ * Asynchronously delivers a signal to a thread. |
+ * |
+ * This function delivers a signal to the thread identified by |tid| within the |
+ * same thread group as the caller. This function requires |
+ * |nacl_signal_set_handler| to be called first, otherwise it will fail with |
+ * ESRCH. |tid| must be a valid thread identifier obtained when creating the |
+ * thread, or 0 to refer to the main thread. Using an invalid |tid| will result |
+ * in undefined behavior. This function is async-signal-safe, and can be used |
+ * within a signal handler. |
+ * @return 0 on success. A positive errno value on error. |
+ */ |
+int nacl_signal_send_async_signal(uintptr_t tid); |
+ |
+#if defined(__cplusplus) |
+} |
+#endif |
+ |
+#endif /* __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_SIGNAL_H__ */ |