From f9c5a696c72d0d7ae2ba2aca5df31840566ad31d Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 8 Jun 2024 14:03:41 -0300 Subject: [PATCH] signal: fix lock ordering issue --- kernel-src/sys/signal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel-src/sys/signal.c b/kernel-src/sys/signal.c index f0995419..a97f7d54 100644 --- a/kernel-src/sys/signal.c +++ b/kernel-src/sys/signal.c @@ -217,6 +217,14 @@ void signal_signalproc(struct proc_t *proc, int signal) { spinlock_release(&proc->threadlistlock); + // if its ignorable and there wasn't any thread with it unmasked, set it as pending for the whole process + // not ignorable signals will be sent to all threads individually + if (notignorable == false && (threadcontinued || shouldstop) == false) { + SIGNAL_SETON(&proc->signals.pending, signal); + } + + PROCESS_LEAVE(proc); + // tell the parent that a child stopped // TODO when stopping make sure that a thread was actually stopped // TODO protect parent with a spinlock @@ -242,14 +250,6 @@ void signal_signalproc(struct proc_t *proc, int signal) { semaphore_signal(&proc->parent->waitsem); } - - // if its ignorable and there wasn't any thread with it unmasked, set it as pending for the whole process - // not ignorable signals will be sent to all threads individually - if (notignorable == false && (threadcontinued || shouldstop) == false) { - SIGNAL_SETON(&proc->signals.pending, signal); - } - - PROCESS_LEAVE(proc); } // returns true if should retry check