mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
signal: Support sigaction:sa_user, siginfo_t:si_user with user info
When the signal sent by the sender is blocked in the target task, if the target task has an action registered with sa_flags SA_KENELHAND, it will directly respond to the action in the context of the sender. When the action is executed, it will have the parameters set by the target task with sigaction:sa_user. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
3927d878e4
commit
9244b5a737
3 changed files with 23 additions and 0 deletions
|
@ -269,6 +269,7 @@
|
|||
* being masked in the handler */
|
||||
#define SA_RESETHAND (1 << 6) /* Clears the handler when the signal
|
||||
* is delivered */
|
||||
#define SA_KERNELHAND (1 << 7) /* Invoke the handler in kernel space directly */
|
||||
|
||||
/* These are the possible values of the signfo si_code field */
|
||||
|
||||
|
@ -371,6 +372,7 @@ struct siginfo
|
|||
#if 0 /* Not implemented */
|
||||
FAR void *si_addr; /* Report address with SIGFPE, SIGSEGV, or SIGBUS */
|
||||
#endif
|
||||
FAR void *si_user; /* The User info associated with sigaction */
|
||||
};
|
||||
|
||||
#ifndef __SIGINFO_T_DEFINED
|
||||
|
@ -401,6 +403,7 @@ struct sigaction
|
|||
} sa_u;
|
||||
sigset_t sa_mask;
|
||||
int sa_flags;
|
||||
FAR void *sa_user;
|
||||
};
|
||||
|
||||
/* Definitions that adjust the non-standard naming */
|
||||
|
|
|
@ -373,6 +373,7 @@ int nxsig_action(int signo, FAR const struct sigaction *act,
|
|||
sigact->act.sa_handler = handler;
|
||||
sigact->act.sa_mask = act->sa_mask;
|
||||
sigact->act.sa_flags = act->sa_flags;
|
||||
sigact->act.sa_user = act->sa_user;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
|
|
@ -214,6 +214,24 @@ static FAR sigpendq_t *
|
|||
return sigpend;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_dispatch_kernel_action
|
||||
****************************************************************************/
|
||||
|
||||
static void nxsig_dispatch_kernel_action(FAR struct tcb_s *stcb,
|
||||
FAR siginfo_t *info)
|
||||
{
|
||||
FAR struct task_group_s *group = stcb->group;
|
||||
FAR sigactq_t *sigact;
|
||||
|
||||
sigact = nxsig_find_action(group, info->si_signo);
|
||||
if (sigact && (sigact->act.sa_flags & SA_KERNELHAND))
|
||||
{
|
||||
info->si_user = sigact->act.sa_user;
|
||||
(sigact->act.sa_sigaction)(info->si_signo, info, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_add_pendingsignal
|
||||
*
|
||||
|
@ -263,6 +281,7 @@ static void nxsig_add_pendingsignal(FAR struct tcb_s *stcb,
|
|||
flags = enter_critical_section();
|
||||
sq_addlast((FAR sq_entry_t *)sigpend, &group->tg_sigpendingq);
|
||||
leave_critical_section(flags);
|
||||
nxsig_dispatch_kernel_action(stcb, &sigpend->info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue