summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-05-05 10:31:24 +0000
committerDamien George <damien.p.george@gmail.com>2016-06-28 11:28:49 +0100
commitc2508ac8bde244494c20dbbe4e01853a23a31328 (patch)
tree4f4cc5396451290256224d8d3c7c4c844b060108 /unix
parent3653f5144a9ad719f70e2d310e218cf724afc822 (diff)
downloadmicropython-c2508ac8bde244494c20dbbe4e01853a23a31328.tar.gz
micropython-c2508ac8bde244494c20dbbe4e01853a23a31328.zip
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.
Diffstat (limited to 'unix')
-rw-r--r--unix/mpthreadport.c10
1 files changed, 7 insertions, 3 deletions
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);
}