diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-21 20:02:14 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-21 20:02:14 +0000 |
commit | 09c1049fff6e991733448e7fb164f518fa003021 (patch) | |
tree | 6f3cae53d1c253af61bab823ff614dd9455f2054 /nuttx/sched | |
parent | aee2b5f63b4eef1751605731688fd80d20593b81 (diff) | |
download | px4-nuttx-09c1049fff6e991733448e7fb164f518fa003021.tar.gz px4-nuttx-09c1049fff6e991733448e7fb164f518fa003021.tar.bz2 px4-nuttx-09c1049fff6e991733448e7fb164f518fa003021.zip |
Copy siginfo_t to step before calling a user-space signal handler
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5769 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r-- | nuttx/sched/sig_deliver.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/nuttx/sched/sig_deliver.c b/nuttx/sched/sig_deliver.c index bb6ca71a4..9b1e8cebe 100644 --- a/nuttx/sched/sig_deliver.c +++ b/nuttx/sched/sig_deliver.c @@ -136,12 +136,25 @@ void sig_deliver(FAR struct tcb_s *stcb) #ifdef CONFIG_NUTTX_KERNEL if ((stcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) { + /* The sigq_t pointed to by sigq resides in kernel space. So we + * cannot pass a reference to sigq->info to the user space. + * Instead, we will copy the siginfo_t structure onto that stack. + * We are currently executing on the stack of the user thread + * (albeit temporarily in kernel mode), so the copy of the + * siginfo_t structure will be accessible by the user thread. + */ + + siginfo_t info; + memcpy(&info, sigq->info, sizeof(siginfo_t)); + up_signal_handler(sigq->action.sighandler, sigq->info.si_signo, - &sigq->info, NULL); + &info, NULL); } else #endif { + /* The kernel thread signal handler is much simpler. */ + (*sigq->action.sighandler)(sigq->info.si_signo, &sigq->info, NULL); } |