Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163957027
D44867.id137400.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D44867.id137400.diff
View Options
diff --git a/include/pthread.h b/include/pthread.h
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -43,6 +43,9 @@
#include <machine/_limits.h>
#include <sys/_types.h>
#include <sys/_sigset.h>
+#if _BSD_VISIBLE
+#include <sys/_sigval.h>
+#endif
#include <sched.h>
#include <time.h>
@@ -302,6 +305,10 @@
int pthread_getname_np(pthread_t, char *, size_t);
int pthread_setname_np(pthread_t, const char *);
+
+int pthread_sigqueue(pthread_t thread, int sig,
+ const union sigval value);
+
#endif
int pthread_mutexattr_getprioceiling(
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -337,3 +337,7 @@
pthread_peekjoin_np;
pthread_setname_np;
};
+
+FBSD_1.8 {
+ pthread_sigqueue;
+};
diff --git a/lib/libthr/thread/Makefile.inc b/lib/libthr/thread/Makefile.inc
--- a/lib/libthr/thread/Makefile.inc
+++ b/lib/libthr/thread/Makefile.inc
@@ -47,6 +47,7 @@
thr_setprio.c \
thr_setschedparam.c \
thr_sig.c \
+ thr_sigqueue.c \
thr_single_np.c \
thr_sleepq.c \
thr_spec.c \
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -1102,6 +1102,7 @@
int __Tthr_mutex_trylock(pthread_mutex_t *);
bool __thr_get_main_stack_base(char **base);
bool __thr_get_main_stack_lim(size_t *lim);
+int _Tthr_sigqueue(pthread_t pthread, int sig, const union sigval value);
__END_DECLS
__NULLABILITY_PRAGMA_POP
diff --git a/lib/libthr/thread/thr_sigqueue.c b/lib/libthr/thread/thr_sigqueue.c
new file mode 100644
--- /dev/null
+++ b/lib/libthr/thread/thr_sigqueue.c
@@ -0,0 +1,79 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
+ * All rights reserved.
+ *
+ * Copyright 2024 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "namespace.h"
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+#include "un-namespace.h"
+
+#include "thr_private.h"
+
+__weak_reference(_Tthr_sigqueue, _pthread_sigqueue);
+__weak_reference(_Tthr_sigqueue, pthread_sigqueue);
+
+int
+_Tthr_sigqueue(pthread_t pthread, int sig, const union sigval value)
+{
+ struct pthread *curthread;
+ int e, ret;
+
+ if (sig < 0 || sig > _SIG_MAXSIG)
+ return (EINVAL);
+
+ curthread = _get_curthread();
+ ret = 0;
+
+ if (curthread == pthread) {
+ if (sig > 0) {
+ e = sigqueue(pthread->tid, sig | __SIGQUEUE_TID,
+ value);
+ if (e == -1)
+ ret = errno;
+ }
+ } else if ((ret = _thr_find_thread(curthread, pthread,
+ 0)) == 0) {
+ if (sig > 0) {
+ e = sigqueue(pthread->tid, sig | __SIGQUEUE_TID,
+ value);
+ if (e == -1)
+ ret = errno;
+ }
+ THR_THREAD_UNLOCK(curthread, pthread);
+ }
+
+ return (ret);
+}
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_ktrace.h"
@@ -2013,13 +2012,16 @@
}
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);
/*
@@ -2029,8 +2031,17 @@
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);
@@ -2040,7 +2051,7 @@
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/kern/kern_thr.c b/sys/kern/kern_thr.c
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -26,11 +26,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "opt_posix.h"
#include "opt_hwpmc_hooks.h"
-#include <sys/param.h>
+
+#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/priv.h>
@@ -39,21 +40,19 @@
#include <sys/ptrace.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
+#include <sys/rtprio.h>
#include <sys/rwlock.h>
#include <sys/sched.h>
#include <sys/sysctl.h>
#include <sys/smp.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
-#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/signalvar.h>
#include <sys/sysctl.h>
-#include <sys/ucontext.h>
#include <sys/thr.h>
-#include <sys/rtprio.h>
+#include <sys/ucontext.h>
#include <sys/umtxvar.h>
-#include <sys/limits.h>
#ifdef HWPMC_HOOKS
#include <sys/pmckern.h>
#endif
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -31,7 +31,6 @@
#include "opt_witness.h"
#include "opt_hwpmc_hooks.h"
-#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
diff --git a/sys/sys/_sigval.h b/sys/sys/_sigval.h
new file mode 100644
--- /dev/null
+++ b/sys/sys/_sigval.h
@@ -0,0 +1,61 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __SYS__SIGVAL_H
+#define __SYS__SIGVAL_H
+
+#if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500
+union sigval {
+ /* Members as suggested by Annex C of POSIX 1003.1b. */
+ int sival_int;
+ void *sival_ptr;
+ /* 6.0 compatibility */
+ int sigval_int;
+ void *sigval_ptr;
+};
+
+#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__))
+union sigval32 {
+ int sival_int;
+ __uint32_t sival_ptr;
+ /* 6.0 compatibility */
+ int sigval_int;
+ __uint32_t sigval_ptr;
+};
+#endif
+#endif
+
+#endif /* __SYS__SIGVAL_H */
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -41,6 +41,7 @@
#include <sys/_types.h>
#include <sys/_sigset.h>
#include <sys/_sigaltstack.h>
+#include <sys/_sigval.h>
#include <machine/_limits.h> /* __MINSIGSTKSZ */
#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */
@@ -165,27 +166,6 @@
#endif
#endif
-#if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500
-union sigval {
- /* Members as suggested by Annex C of POSIX 1003.1b. */
- int sival_int;
- void *sival_ptr;
- /* 6.0 compatibility */
- int sigval_int;
- void *sigval_ptr;
-};
-
-#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__))
-union sigval32 {
- int sival_int;
- uint32_t sival_ptr;
- /* 6.0 compatibility */
- int sigval_int;
- uint32_t sigval_ptr;
-};
-#endif
-#endif
-
#if __POSIX_VISIBLE >= 199309
struct pthread_attr;
@@ -475,6 +455,10 @@
#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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 28, 11:21 AM (6 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35649580
Default Alt Text
D44867.id137400.diff (10 KB)
Attached To
Mode
D44867: Add pthread_sigqueue(3)
Attached
Detach File
Event Timeline
Log In to Comment