git: ed9e2991c2da - stable/14 - sigqueue(2): add impl-specific flag __SIGQUEUE_TID
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Apr 2024 00:48:58 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=ed9e2991c2da5924a1876383dbe9a51e1015b69e
commit ed9e2991c2da5924a1876383dbe9a51e1015b69e
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-19 14:29:05 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-04-30 00:48:09 +0000
sigqueue(2): add impl-specific flag __SIGQUEUE_TID
(cherry picked from commit 53186bc1435e2c3ccf9c2124c066a08c6a80c504)
---
sys/kern/kern_sig.c | 22 +++++++++++++++++-----
sys/sys/signal.h | 4 ++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 54e39d2cd310..2f2ec7edfb12 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -2010,13 +2010,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);
/*
@@ -2026,8 +2029,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);
@@ -2037,7 +2049,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);
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index 4007c6968eae..2165a9655a10 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -499,6 +499,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