Last active
September 19, 2016 09:54
-
-
Save rolfbjarne/6aab59c1609f33402d195f9c34e9f99b to your computer and use it in GitHub Desktop.
mono_runtime_install_chained_signal_handler.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit fe39d32800002f60624bcf6b48f6ba17b967c7ac | |
Author: Rolf Bjarne Kvinge <rolf@xamarin.com> | |
Date: Tue Sep 13 13:19:25 2016 +0200 | |
[mini] Add API to change/install the saved signal handler for a signal. | |
diff --git a/mono/mini/mini-posix.c b/mono/mini/mini-posix.c | |
index e192403..770a33c 100644 | |
--- a/mono/mini/mini-posix.c | |
+++ b/mono/mini/mini-posix.c | |
@@ -181,6 +181,30 @@ free_saved_signal_handlers (void) | |
} | |
/* | |
+ * mono_runtime_install_chained_signal_handler: | |
+ * | |
+ * Installs a signal handler that will be called when mono | |
+ * handles a signal and determines the signal occurred in | |
+ * code that mono does not care about. | |
+ * | |
+ */ | |
+void | |
+mono_runtime_install_chained_signal_handler (int signal, const struct sigaction *handler, struct sigaction *previous_handler) | |
+{ | |
+ gpointer original_value; | |
+ | |
+ if (!mono_saved_signal_handlers) | |
+ mono_saved_signal_handlers = g_hash_table_new_full (NULL, NULL, NULL, g_free); | |
+ | |
+ if (previous_handler && g_hash_table_lookup_extended (mono_saved_signal_handlers, GINT_TO_POINTER (signal), NULL, &original_value)) | |
+ *previous_handler = *(struct sigaction *) original_value; | |
+ | |
+ struct sigaction *handler_to_save = (struct sigaction *) g_malloc (sizeof (struct sigaction)); | |
+ *handler_to_save = *handler; | |
+ g_hash_table_replace (mono_saved_signal_handlers, GINT_TO_POINTER (signal), handler_to_save); | |
+} | |
+ | |
+/* | |
* mono_chain_signal: | |
* | |
* Call the original signal handler for the signal given by the arguments, which | |
diff --git a/mono/mini/mini.h b/mono/mini/mini.h | |
index 845162f..c6fc1ea 100644 | |
--- a/mono/mini/mini.h | |
+++ b/mono/mini/mini.h | |
@@ -3153,6 +3153,7 @@ void mono_runtime_cleanup_handlers (void); | |
void mono_runtime_setup_stat_profiler (void); | |
void mono_runtime_shutdown_stat_profiler (void); | |
void mono_runtime_posix_install_handlers (void); | |
+void mono_runtime_install_chained_signal_handler (int signal, const struct sigaction *handler, struct sigaction *previous_handler); | |
pid_t mono_runtime_syscall_fork (void); | |
void mono_gdb_render_native_backtraces (pid_t crashed_pid); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment