18269e767SBrooks Davis.\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org> 28269e767SBrooks Davis.\" All rights reserved. 38269e767SBrooks Davis.\" 48269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 58269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 68269e767SBrooks Davis.\" are met: 78269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 88269e767SBrooks Davis.\" notice(s), this list of conditions and the following disclaimer as 98269e767SBrooks Davis.\" the first lines of this file unmodified other than the possible 108269e767SBrooks Davis.\" addition of one or more copyright notices. 118269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 128269e767SBrooks Davis.\" notice(s), this list of conditions and the following disclaimer in 138269e767SBrooks Davis.\" the documentation and/or other materials provided with the 148269e767SBrooks Davis.\" distribution. 158269e767SBrooks Davis.\" 168269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 178269e767SBrooks Davis.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 198269e767SBrooks Davis.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 208269e767SBrooks Davis.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 218269e767SBrooks Davis.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 228269e767SBrooks Davis.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 238269e767SBrooks Davis.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 248269e767SBrooks Davis.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 258269e767SBrooks Davis.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 268269e767SBrooks Davis.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 278269e767SBrooks Davis.\" 28*dcc180c5SKonstantin Belousov.Dd April 21, 2024 298269e767SBrooks Davis.Dt SIGQUEUE 2 308269e767SBrooks Davis.Os 318269e767SBrooks Davis.Sh NAME 328269e767SBrooks Davis.Nm sigqueue 338269e767SBrooks Davis.Nd "queue a signal to a process (REALTIME)" 348269e767SBrooks Davis.Sh LIBRARY 358269e767SBrooks Davis.Lb libc 368269e767SBrooks Davis.Sh SYNOPSIS 378269e767SBrooks Davis.In signal.h 388269e767SBrooks Davis.Ft int 398269e767SBrooks Davis.Fn sigqueue "pid_t pid" "int signo" "const union sigval value" 408269e767SBrooks Davis.Sh DESCRIPTION 418269e767SBrooks DavisThe 428269e767SBrooks Davis.Fn sigqueue 438269e767SBrooks Davissystem call causes the signal specified by 448269e767SBrooks Davis.Fa signo 458269e767SBrooks Davisto be sent with the value specified by 468269e767SBrooks Davis.Fa value 478269e767SBrooks Davisto the process specified by 488269e767SBrooks Davis.Fa pid . 498269e767SBrooks DavisIf 508269e767SBrooks Davis.Fa signo 518269e767SBrooks Davisis zero (the null signal), error checking is performed but 528269e767SBrooks Davisno signal is actually sent. 538269e767SBrooks DavisThe null signal can be used to check the 548269e767SBrooks Davisvalidity of PID. 558269e767SBrooks Davis.Pp 568269e767SBrooks DavisThe conditions required for a process to have permission to queue a 578269e767SBrooks Davissignal to another process are the same as for the 588269e767SBrooks Davis.Xr kill 2 598269e767SBrooks Davissystem call. 608269e767SBrooks DavisThe 618269e767SBrooks Davis.Fn sigqueue 628269e767SBrooks Davissystem call queues a signal to a single process specified by the 638269e767SBrooks Davis.Fa pid 648269e767SBrooks Davisargument. 658269e767SBrooks Davis.Pp 668269e767SBrooks DavisThe 678269e767SBrooks Davis.Fn sigqueue 688269e767SBrooks Davissystem call returns immediately. 698269e767SBrooks DavisIf the resources were 708269e767SBrooks Davisavailable to queue the signal, the signal will be queued and sent to 718269e767SBrooks Davisthe receiving process. 728269e767SBrooks Davis.Pp 738269e767SBrooks DavisIf the value of 748269e767SBrooks Davis.Fa pid 758269e767SBrooks Daviscauses 768269e767SBrooks Davis.Fa signo 778269e767SBrooks Davisto be generated for the sending process, and if 788269e767SBrooks Davis.Fa signo 798269e767SBrooks Davisis not blocked for the calling thread and if no other thread has 808269e767SBrooks Davis.Fa signo 818269e767SBrooks Davisunblocked or is waiting in a 828269e767SBrooks Davis.Fn sigwait 838269e767SBrooks Davissystem call for 848269e767SBrooks Davis.Fa signo , 858269e767SBrooks Daviseither 868269e767SBrooks Davis.Fa signo 878269e767SBrooks Davisor at least the pending, unblocked signal will be delivered to the 888269e767SBrooks Daviscalling thread before 898269e767SBrooks Davis.Fn sigqueue 908269e767SBrooks Davisreturns. 918269e767SBrooks DavisShould any multiple pending signals in the range 928269e767SBrooks Davis.Dv SIGRTMIN 938269e767SBrooks Davisto 948269e767SBrooks Davis.Dv SIGRTMAX 958269e767SBrooks Davisbe selected for delivery, it is the lowest numbered 968269e767SBrooks Davisone. 978269e767SBrooks DavisThe selection order between realtime and non-realtime signals, or 988269e767SBrooks Davisbetween multiple pending non-realtime signals, is unspecified. 99*dcc180c5SKonstantin Belousov.Pp 100*dcc180c5SKonstantin BelousovAs a 101*dcc180c5SKonstantin Belousov.Fx 102*dcc180c5SKonstantin Belousovextension, the value of 103*dcc180c5SKonstantin Belousov.Fa signo 104*dcc180c5SKonstantin Belousovcan be or-ed with the following flags: 105*dcc180c5SKonstantin Belousov.Bl -tag -width __SIGQUEUE_TID 106*dcc180c5SKonstantin Belousov.It Dv __SIGQUEUE_TID 107*dcc180c5SKonstantin BelousovThe 108*dcc180c5SKonstantin Belousov.Fa pid 109*dcc180c5SKonstantin Belousovparameter is the thread identifier of a thread in the current process, 110*dcc180c5SKonstantin Belousovand the specified signal is queued into the specified thread' queue. 111*dcc180c5SKonstantin Belousov.El 1128269e767SBrooks Davis.Sh RETURN VALUES 1138269e767SBrooks Davis.Rv -std 1148269e767SBrooks Davis.Sh ERRORS 1158269e767SBrooks DavisThe 1168269e767SBrooks Davis.Fn sigqueue 1178269e767SBrooks Davissystem call 1188269e767SBrooks Daviswill fail if: 1198269e767SBrooks Davis.Bl -tag -width Er 1208269e767SBrooks Davis.It Bq Er EAGAIN 1218269e767SBrooks DavisNo resources are available to queue the signal. 1228269e767SBrooks DavisThe process has already 1238269e767SBrooks Davisqueued 1248269e767SBrooks Davis.Brq Dv SIGQUEUE_MAX 1258269e767SBrooks Davissignals that are still pending at the receiver(s), 1268269e767SBrooks Davisor a system-wide resource limit has been exceeded. 1278269e767SBrooks Davis.It Bq Er EINVAL 1288269e767SBrooks DavisThe value of the 1298269e767SBrooks Davis.Fa signo 1308269e767SBrooks Davisargument is an invalid or unsupported signal number. 1318269e767SBrooks Davis.It Bq Er EPERM 1328269e767SBrooks DavisThe process does not have the appropriate privilege to send the signal 1338269e767SBrooks Davisto the receiving process. 1348269e767SBrooks Davis.It Bq Er ESRCH 1358269e767SBrooks DavisThe process 1368269e767SBrooks Davis.Fa pid 1378269e767SBrooks Davisdoes not exist. 138*dcc180c5SKonstantin Belousov.It Bq Er ESRCH 139*dcc180c5SKonstantin BelousovThe thread with id 140*dcc180c5SKonstantin Belousov.Fa pid 141*dcc180c5SKonstantin Belousovdoes not exist in the current process. 1428269e767SBrooks Davis.El 1438269e767SBrooks Davis.Sh SEE ALSO 1448269e767SBrooks Davis.Xr kill 2 , 1458269e767SBrooks Davis.Xr sigaction 2 , 1468269e767SBrooks Davis.Xr sigpending 2 , 1478269e767SBrooks Davis.Xr sigsuspend 2 , 1488269e767SBrooks Davis.Xr sigtimedwait 2 , 1498269e767SBrooks Davis.Xr sigwait 2 , 1508269e767SBrooks Davis.Xr sigwaitinfo 2 , 1518269e767SBrooks Davis.Xr pause 3 , 1528269e767SBrooks Davis.Xr pthread_sigmask 3 , 1538269e767SBrooks Davis.Xr siginfo 3 1548269e767SBrooks Davis.Sh STANDARDS 1558269e767SBrooks DavisThe 1568269e767SBrooks Davis.Fn sigqueue 1578269e767SBrooks Davissystem call conforms to 1588269e767SBrooks Davis.St -p1003.1-2004 . 1598269e767SBrooks Davis.Sh HISTORY 1608269e767SBrooks DavisSupport for 1618269e767SBrooks Davis.Tn POSIX 1628269e767SBrooks Davisrealtime signal queue first appeared in 1638269e767SBrooks Davis.Fx 7.0 . 1648269e767SBrooks Davis.Sh CAVEATS 1658269e767SBrooks DavisWhen using 1668269e767SBrooks Davis.Nm 1678269e767SBrooks Davisto send signals to a process which might have a different ABI 1688269e767SBrooks Davis(for instance, one is 32-bit and the other 64-bit), 1698269e767SBrooks Davisthe 1708269e767SBrooks Davis.Va sival_int 1718269e767SBrooks Davismember of 1728269e767SBrooks Davis.Fa value 1738269e767SBrooks Daviscan be delivered reliably, but the 1748269e767SBrooks Davis.Va sival_ptr 1758269e767SBrooks Davismay be truncated in endian dependent ways and must not be relied on. 1768269e767SBrooks DavisFurther, many pointer integrity schemes disallow sending pointers to other 1778269e767SBrooks Davisprocesses, and this technique should not be used in programs intended to 1788269e767SBrooks Davisbe portable. 179