15507a2aeSRuslan Ermilov.\" Copyright (c) 2005 David Xu <[email protected]> 2b1e515a3SDavid Xu.\" All rights reserved. 3e84ece6bSDavid Xu.\" 4e84ece6bSDavid Xu.\" Redistribution and use in source and binary forms, with or without 5e84ece6bSDavid Xu.\" modification, are permitted provided that the following conditions 6e84ece6bSDavid Xu.\" are met: 7e84ece6bSDavid Xu.\" 1. Redistributions of source code must retain the above copyright 8e84ece6bSDavid Xu.\" notice(s), this list of conditions and the following disclaimer as 9e84ece6bSDavid Xu.\" the first lines of this file unmodified other than the possible 10e84ece6bSDavid Xu.\" addition of one or more copyright notices. 11e84ece6bSDavid Xu.\" 2. Redistributions in binary form must reproduce the above copyright 12e84ece6bSDavid Xu.\" notice(s), this list of conditions and the following disclaimer in 13e84ece6bSDavid Xu.\" the documentation and/or other materials provided with the 14e84ece6bSDavid Xu.\" distribution. 15e84ece6bSDavid Xu.\" 16e84ece6bSDavid Xu.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 17e84ece6bSDavid Xu.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18e84ece6bSDavid Xu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19e84ece6bSDavid Xu.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 20e84ece6bSDavid Xu.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21e84ece6bSDavid Xu.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22e84ece6bSDavid Xu.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23e84ece6bSDavid Xu.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24e84ece6bSDavid Xu.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25e84ece6bSDavid Xu.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26e84ece6bSDavid Xu.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27e84ece6bSDavid Xu.\" 28*afc8b178SKonstantin Belousov.Dd April 21, 2024 29e84ece6bSDavid Xu.Dt SIGQUEUE 2 30e84ece6bSDavid Xu.Os 31e84ece6bSDavid Xu.Sh NAME 32e84ece6bSDavid Xu.Nm sigqueue 335507a2aeSRuslan Ermilov.Nd "queue a signal to a process (REALTIME)" 34e84ece6bSDavid Xu.Sh LIBRARY 35e84ece6bSDavid Xu.Lb libc 36e84ece6bSDavid Xu.Sh SYNOPSIS 37e84ece6bSDavid Xu.In signal.h 38e84ece6bSDavid Xu.Ft int 39e84ece6bSDavid Xu.Fn sigqueue "pid_t pid" "int signo" "const union sigval value" 40e84ece6bSDavid Xu.Sh DESCRIPTION 41e84ece6bSDavid XuThe 42e84ece6bSDavid Xu.Fn sigqueue 435507a2aeSRuslan Ermilovsystem call causes the signal specified by 44e84ece6bSDavid Xu.Fa signo 45e84ece6bSDavid Xuto be sent with the value specified by 46e84ece6bSDavid Xu.Fa value 47e84ece6bSDavid Xuto the process specified by 48e84ece6bSDavid Xu.Fa pid . 49e84ece6bSDavid XuIf 50e84ece6bSDavid Xu.Fa signo 51e84ece6bSDavid Xuis zero (the null signal), error checking is performed but 525507a2aeSRuslan Ermilovno signal is actually sent. 535507a2aeSRuslan ErmilovThe null signal can be used to check the 545507a2aeSRuslan Ermilovvalidity of PID. 55e84ece6bSDavid Xu.Pp 56e84ece6bSDavid XuThe conditions required for a process to have permission to queue a 57e84ece6bSDavid Xusignal to another process are the same as for the 585507a2aeSRuslan Ermilov.Xr kill 2 595507a2aeSRuslan Ermilovsystem call. 60e84ece6bSDavid XuThe 61e84ece6bSDavid Xu.Fn sigqueue 625507a2aeSRuslan Ermilovsystem call queues a signal to a single process specified by the 635507a2aeSRuslan Ermilov.Fa pid 645507a2aeSRuslan Ermilovargument. 65e84ece6bSDavid Xu.Pp 665507a2aeSRuslan ErmilovThe 675507a2aeSRuslan Ermilov.Fn sigqueue 685507a2aeSRuslan Ermilovsystem call returns immediately. 695507a2aeSRuslan ErmilovIf the resources were 70e84ece6bSDavid Xuavailable to queue the signal, the signal will be queued and sent to 71e84ece6bSDavid Xuthe receiving process. 72e84ece6bSDavid Xu.Pp 73e84ece6bSDavid XuIf the value of 74e84ece6bSDavid Xu.Fa pid 75e84ece6bSDavid Xucauses 76e84ece6bSDavid Xu.Fa signo 77e84ece6bSDavid Xuto be generated for the sending process, and if 78e84ece6bSDavid Xu.Fa signo 79e84ece6bSDavid Xuis not blocked for the calling thread and if no other thread has 80e84ece6bSDavid Xu.Fa signo 81e84ece6bSDavid Xuunblocked or is waiting in a 82e84ece6bSDavid Xu.Fn sigwait 835507a2aeSRuslan Ermilovsystem call for 84b71ec5beSDavid Xu.Fa signo , 85b71ec5beSDavid Xueither 86e84ece6bSDavid Xu.Fa signo 87e84ece6bSDavid Xuor at least the pending, unblocked signal will be delivered to the 885507a2aeSRuslan Ermilovcalling thread before 89e84ece6bSDavid Xu.Fn sigqueue 905507a2aeSRuslan Ermilovreturns. 915507a2aeSRuslan ErmilovShould any multiple pending signals in the range 925507a2aeSRuslan Ermilov.Dv SIGRTMIN 935507a2aeSRuslan Ermilovto 945507a2aeSRuslan Ermilov.Dv SIGRTMAX 955507a2aeSRuslan Ermilovbe selected for delivery, it is the lowest numbered 965507a2aeSRuslan Ermilovone. 975507a2aeSRuslan ErmilovThe selection order between realtime and non-realtime signals, or 98e84ece6bSDavid Xubetween multiple pending non-realtime signals, is unspecified. 99*afc8b178SKonstantin Belousov.Pp 100*afc8b178SKonstantin BelousovAs a 101*afc8b178SKonstantin Belousov.Fx 102*afc8b178SKonstantin Belousovextension, the value of 103*afc8b178SKonstantin Belousov.Fa signo 104*afc8b178SKonstantin Belousovcan be or-ed with the following flags: 105*afc8b178SKonstantin Belousov.Bl -tag -width __SIGQUEUE_TID 106*afc8b178SKonstantin Belousov.It Dv __SIGQUEUE_TID 107*afc8b178SKonstantin BelousovThe 108*afc8b178SKonstantin Belousov.Fa pid 109*afc8b178SKonstantin Belousovparameter is the thread identifier of a thread in the current process, 110*afc8b178SKonstantin Belousovand the specified signal is queued into the specified thread' queue. 111*afc8b178SKonstantin Belousov.El 112e84ece6bSDavid Xu.Sh RETURN VALUES 1135507a2aeSRuslan Ermilov.Rv -std 114e84ece6bSDavid Xu.Sh ERRORS 115e84ece6bSDavid XuThe 116e84ece6bSDavid Xu.Fn sigqueue 1175507a2aeSRuslan Ermilovsystem call 118e84ece6bSDavid Xuwill fail if: 119e84ece6bSDavid Xu.Bl -tag -width Er 120e84ece6bSDavid Xu.It Bq Er EAGAIN 1215507a2aeSRuslan ErmilovNo resources are available to queue the signal. 1225507a2aeSRuslan ErmilovThe process has already 1235507a2aeSRuslan Ermilovqueued 1245507a2aeSRuslan Ermilov.Brq Dv SIGQUEUE_MAX 1255507a2aeSRuslan Ermilovsignals that are still pending at the receiver(s), 126e84ece6bSDavid Xuor a system-wide resource limit has been exceeded. 127e84ece6bSDavid Xu.It Bq Er EINVAL 128e84ece6bSDavid XuThe value of the 129e84ece6bSDavid Xu.Fa signo 130e84ece6bSDavid Xuargument is an invalid or unsupported signal number. 13108851ea2SJilles Tjoelker.It Bq Er EPERM 132e84ece6bSDavid XuThe process does not have the appropriate privilege to send the signal 133e84ece6bSDavid Xuto the receiving process. 134e84ece6bSDavid Xu.It Bq Er ESRCH 1355507a2aeSRuslan ErmilovThe process 1365507a2aeSRuslan Ermilov.Fa pid 1375507a2aeSRuslan Ermilovdoes not exist. 138*afc8b178SKonstantin Belousov.It Bq Er ESRCH 139*afc8b178SKonstantin BelousovThe thread with id 140*afc8b178SKonstantin Belousov.Fa pid 141*afc8b178SKonstantin Belousovdoes not exist in the current process. 142e84ece6bSDavid Xu.El 143e84ece6bSDavid Xu.Sh SEE ALSO 1446975edd9SEdward Tomasz Napierala.Xr kill 2 , 145e84ece6bSDavid Xu.Xr sigaction 2 , 146e84ece6bSDavid Xu.Xr sigpending 2 , 147e84ece6bSDavid Xu.Xr sigsuspend 2 , 1485507a2aeSRuslan Ermilov.Xr sigtimedwait 2 , 1495507a2aeSRuslan Ermilov.Xr sigwait 2 , 1505507a2aeSRuslan Ermilov.Xr sigwaitinfo 2 , 151e84ece6bSDavid Xu.Xr pause 3 , 152a73a3ab5SRuslan Ermilov.Xr pthread_sigmask 3 , 153412295fdSDavid Xu.Xr siginfo 3 154e84ece6bSDavid Xu.Sh STANDARDS 155e84ece6bSDavid XuThe 156e84ece6bSDavid Xu.Fn sigqueue 1575507a2aeSRuslan Ermilovsystem call conforms to 1589f63b422SGlen Barber.St -p1003.1-2004 . 1596f59c4c0SDavid Xu.Sh HISTORY 160a73a3ab5SRuslan ErmilovSupport for 161a73a3ab5SRuslan Ermilov.Tn POSIX 162a73a3ab5SRuslan Ermilovrealtime signal queue first appeared in 1636f59c4c0SDavid Xu.Fx 7.0 . 164f19351aaSBrooks Davis.Sh CAVEATS 165f19351aaSBrooks DavisWhen using 166f19351aaSBrooks Davis.Nm 167f19351aaSBrooks Davisto send signals to a process which might have a different ABI 168f19351aaSBrooks Davis(for instance, one is 32-bit and the other 64-bit), 169f19351aaSBrooks Davisthe 170f19351aaSBrooks Davis.Va sival_int 171f19351aaSBrooks Davismember of 172f19351aaSBrooks Davis.Fa value 173f19351aaSBrooks Daviscan be delivered reliably, but the 174f19351aaSBrooks Davis.Va sival_ptr 175f19351aaSBrooks Davismay be truncated in endian dependent ways and must not be relied on. 176f19351aaSBrooks DavisFurther, many pointer integrity schemes disallow sending pointers to other 177f19351aaSBrooks Davisprocesses, and this technique should not be used in programs intended to 178f19351aaSBrooks Davisbe portable. 179