From c2508ac8bde244494c20dbbe4e01853a23a31328 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 5 May 2016 10:31:24 +0000 Subject: unix/mpthreadport: Use SA_SIGINFO for GC signal handler. SA_SIGINFO allows the signal handler to access more information about the signal, especially useful in a threaded environment. The extra information is not currently used but it may prove useful in the future. --- unix/mpthreadport.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'unix/mpthreadport.c') diff --git a/unix/mpthreadport.c b/unix/mpthreadport.c index d821f27241..e11a79b471 100644 --- a/unix/mpthreadport.c +++ b/unix/mpthreadport.c @@ -56,10 +56,14 @@ STATIC thread_t *thread; STATIC volatile int thread_signal_done; // this signal handler is used to scan the regs and stack of a thread -STATIC void mp_thread_gc(int signo) { +STATIC void mp_thread_gc(int signo, siginfo_t *info, void *context) { if (signo == SIGUSR1) { void gc_collect_regs_and_stack(void); gc_collect_regs_and_stack(); + // We have access to the context (regs, stack) of the thread but it seems + // that we don't need the extra information, enough is captured by the + // gc_collect_regs_and_stack function above + //gc_collect_root((void**)context, sizeof(ucontext_t) / sizeof(uintptr_t)); thread_signal_done = 1; } } @@ -77,8 +81,8 @@ void mp_thread_init(void) { // enable signal handler for garbage collection struct sigaction sa; - sa.sa_flags = 0; - sa.sa_handler = mp_thread_gc; + sa.sa_flags = SA_SIGINFO; + sa.sa_sigaction = mp_thread_gc; sigemptyset(&sa.sa_mask); sigaction(SIGUSR1, &sa, NULL); } -- cgit v1.2.3