mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 10:48:02 +00:00
sigqueue(2): add impl-specific flag __SIGQUEUE_TID
The flag allows the pid argument to designate a thread from the calling process. The flag value is carved from the high bit of the signal number, which slightly changes the ABI of syscall. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44867
This commit is contained in:
parent
0c11c1792b
commit
53186bc143
|
@ -2012,13 +2012,16 @@ sys_sigqueue(struct thread *td, struct sigqueue_args *uap)
|
|||
}
|
||||
|
||||
int
|
||||
kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value)
|
||||
kern_sigqueue(struct thread *td, pid_t pid, int signumf, union sigval *value)
|
||||
{
|
||||
ksiginfo_t ksi;
|
||||
struct proc *p;
|
||||
struct thread *td2;
|
||||
u_int signum;
|
||||
int error;
|
||||
|
||||
if ((u_int)signum > _SIG_MAXSIG)
|
||||
signum = signumf & ~__SIGQUEUE_TID;
|
||||
if (signum > _SIG_MAXSIG)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
|
@ -2028,8 +2031,17 @@ kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value)
|
|||
if (pid <= 0)
|
||||
return (EINVAL);
|
||||
|
||||
if ((p = pfind_any(pid)) == NULL)
|
||||
return (ESRCH);
|
||||
if ((signumf & __SIGQUEUE_TID) == 0) {
|
||||
if ((p = pfind_any(pid)) == NULL)
|
||||
return (ESRCH);
|
||||
td2 = NULL;
|
||||
} else {
|
||||
p = td->td_proc;
|
||||
td2 = tdfind((lwpid_t)pid, p->p_pid);
|
||||
if (td2 == NULL)
|
||||
return (ESRCH);
|
||||
}
|
||||
|
||||
error = p_cansignal(td, p, signum);
|
||||
if (error == 0 && signum != 0) {
|
||||
ksiginfo_init(&ksi);
|
||||
|
@ -2039,7 +2051,7 @@ kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value)
|
|||
ksi.ksi_pid = td->td_proc->p_pid;
|
||||
ksi.ksi_uid = td->td_ucred->cr_ruid;
|
||||
ksi.ksi_value = *value;
|
||||
error = pksignal(p, ksi.ksi_signo, &ksi);
|
||||
error = tdsendsignal(p, td2, ksi.ksi_signo, &ksi);
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
return (error);
|
||||
|
|
|
@ -475,6 +475,10 @@ struct sigstack {
|
|||
|
||||
#if __BSD_VISIBLE
|
||||
#define BADSIG SIG_ERR
|
||||
|
||||
/* sigqueue(2) signo high-bits flags */
|
||||
#define __SIGQUEUE_TID 0x80000000 /* queue for tid, instead of pid */
|
||||
#define __SIGQUEUE_RSRV 0x40000000 /* reserved */
|
||||
#endif
|
||||
|
||||
#if __POSIX_VISIBLE || __XSI_VISIBLE
|
||||
|
|
Loading…
Reference in a new issue