Skip to content

Instantly share code, notes, and snippets.

@radical
Created May 17, 2018 18:20
Show Gist options
  • Save radical/297c61c28ebad881d2d2060f22f15762 to your computer and use it in GitHub Desktop.
Save radical/297c61c28ebad881d2d2060f22f15762 to your computer and use it in GitHub Desktop.
diff --git a/mono/mini/mini-posix.c b/mono/mini/mini-posix.c
index 33b1edb9a41..3989dd0b8ec 100644
--- a/mono/mini/mini-posix.c
+++ b/mono/mini/mini-posix.c
@@ -50,6 +50,7 @@
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/metadata/attach.h>
+#include <mono/metadata/runtime.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-counters.h>
@@ -218,6 +219,15 @@ MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)
if (mono_merp_enabled ())
mono_handle_native_crash ("SIGTERM", ctx, info);
+ if (!mono_runtime_try_shutdown ()) {
+ mono_thread_exit();
+ }
+
+ /* Suspend all managed threads since the runtime is going away */
+ mono_thread_suspend_all_other_threads ();
+
+ mono_runtime_quit ();
+
mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
exit (1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment