Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -5741,6 +5741,8 @@ ves_icall_Mono_Runtime_EnableMicrosoftTelemetry (char *appBundleID, char *appSig
{
#ifdef TARGET_OSX
mono_merp_enable (appBundleID, appSignature, appVersion, merpGUIPath);

mono_get_runtime_callbacks ()->runtime_telemetry_callback ();
#else
// Icall has platform check in managed too.
g_assert_not_reached ();
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/object-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ typedef struct {
gpointer (*create_delegate_trampoline) (MonoDomain *domain, MonoClass *klass);
gpointer (*interp_get_remoting_invoke) (gpointer imethod, MonoError *error);
GHashTable *(*get_weak_field_indexes) (MonoImage *image);
void (*runtime_telemetry_callback) (void);
} MonoRuntimeCallbacks;

typedef gboolean (*MonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data);
Expand Down
24 changes: 24 additions & 0 deletions mono/mini/mini-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <mach/clock.h>
#include <mono/utils/mono-merp.h>
#endif

#if defined(HOST_WATCHOS)
Expand Down Expand Up @@ -210,6 +211,20 @@ MONO_SIG_HANDLER_FUNC (static, sigabrt_signal_handler)
}
}

#ifdef TARGET_OSX
MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler)
{
MONO_SIG_HANDLER_INFO_TYPE *info = MONO_SIG_HANDLER_GET_INFO ();
MONO_SIG_HANDLER_GET_CONTEXT;

if (mono_merp_enabled ())
mono_handle_native_crash ("SIGTERM", ctx, info);

mono_chain_signal (MONO_SIG_HANDLER_PARAMS);
exit (1);
}
#endif

#if (defined (USE_POSIX_BACKEND) && defined (SIGRTMIN)) || defined (SIGPROF)
#define HAVE_PROFILER_SIGNAL
#endif
Expand Down Expand Up @@ -361,6 +376,15 @@ remove_signal_handler (int signo)
}
}

#ifdef TARGET_OSX
void
mini_register_sigterm_handler (void)
{
/* always catch SIGTERM, conditionals inside of handler */
add_signal_handler (SIGTERM, sigterm_signal_handler, 0);
}
#endif

void
mono_runtime_posix_install_handlers (void)
{
Expand Down
4 changes: 4 additions & 0 deletions mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4040,6 +4040,10 @@ mini_init (const char *filename, const char *runtime_version)
#endif
callbacks.get_weak_field_indexes = mono_aot_get_weak_field_indexes;

#ifdef TARGET_OSX
callbacks.runtime_telemetry_callback = mini_register_sigterm_handler;
#endif

mono_install_callbacks (&callbacks);

memset (&ticallbacks, 0, sizeof (ticallbacks));
Expand Down
4 changes: 4 additions & 0 deletions mono/mini/mini-runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,5 +528,9 @@ gboolean MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal);
#define DISABLE_SDB 1
#endif

#ifdef TARGET_OSX
void mini_register_sigterm_handler (void);
#endif

#endif /* __MONO_MINI_RUNTIME_H__ */