From 0648a616680c9cf4332525f8894bfc280a4d9f2b Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Wed, 22 Nov 2023 15:48:04 +0200 Subject: [PATCH] sigaction: Expand si_user for non-kernel signals Commit 9244b5a737c9222aa3df3eac167f76ce7e7e50b8 added support for non-standard field si_user that is useful for passing context pointers to signal handlers. This commits makes it work for all signals, not just SA_KERNELHAND. Previously si_user for normal signals was uninitialized garbage. --- include/signal.h | 2 +- sched/signal/sig_dispatch.c | 1 + sched/signal/sig_queue.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/signal.h b/include/signal.h index 84ee27e823..3215f04b1e 100644 --- a/include/signal.h +++ b/include/signal.h @@ -390,7 +390,7 @@ struct sigaction } sa_u; sigset_t sa_mask; int sa_flags; - FAR void *sa_user; + FAR void *sa_user; /* Passed to siginfo.si_user (non-standard) */ }; /* Definitions that adjust the non-standard naming */ diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c index 0d3c7b646d..d910fb0904 100644 --- a/sched/signal/sig_dispatch.c +++ b/sched/signal/sig_dispatch.c @@ -101,6 +101,7 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info) } memcpy(&sigq->info, info, sizeof(siginfo_t)); + sigq->info.si_user = sigact->act.sa_user; /* Put it at the end of the pending signals list */ diff --git a/sched/signal/sig_queue.c b/sched/signal/sig_queue.c index 6b9651806c..a611f63cc2 100644 --- a/sched/signal/sig_queue.c +++ b/sched/signal/sig_queue.c @@ -101,6 +101,7 @@ int nxsig_queue(int pid, int signo, union sigval value) info.si_pid = rtcb->pid; info.si_status = OK; #endif + info.si_user = NULL; /* Will be set in sig_dispatch.c */ /* Send the signal */