Skip to content
Snippets Groups Projects
Commit c2508ac8 authored by Damien George's avatar Damien George
Browse files

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.
parent 3653f514
Branches
No related tags found
No related merge requests found
...@@ -56,10 +56,14 @@ STATIC thread_t *thread; ...@@ -56,10 +56,14 @@ STATIC thread_t *thread;
STATIC volatile int thread_signal_done; STATIC volatile int thread_signal_done;
// this signal handler is used to scan the regs and stack of a thread // 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) { if (signo == SIGUSR1) {
void gc_collect_regs_and_stack(void); void gc_collect_regs_and_stack(void);
gc_collect_regs_and_stack(); 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; thread_signal_done = 1;
} }
} }
...@@ -77,8 +81,8 @@ void mp_thread_init(void) { ...@@ -77,8 +81,8 @@ void mp_thread_init(void) {
// enable signal handler for garbage collection // enable signal handler for garbage collection
struct sigaction sa; struct sigaction sa;
sa.sa_flags = 0; sa.sa_flags = SA_SIGINFO;
sa.sa_handler = mp_thread_gc; sa.sa_sigaction = mp_thread_gc;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, NULL); sigaction(SIGUSR1, &sa, NULL);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment