]>
Commit | Line | Data |
---|---|---|
c11b1abf | 1 | .\" Copyright (c) 2002 Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 2 | .\" |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
10d76543 MK |
16 | .\" the use of the information contained herein. The author(s) may not |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
d9bfdb9c | 25 | .\" added note on self-signaling, aeb, 2002-06-07 |
fea681da MK |
26 | .\" added note on CAP_KILL, mtk, 2004-06-16 |
27 | .\" | |
4b8c67d9 | 28 | .TH SIGQUEUE 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
fea681da | 29 | .SH NAME |
46d7906b | 30 | sigqueue \- queue a signal and data to a process |
fea681da MK |
31 | .SH SYNOPSIS |
32 | .B #include <signal.h> | |
68e4db0a | 33 | .PP |
c10859eb | 34 | .BI "int sigqueue(pid_t " pid ", int " sig ", const union sigval " value ); |
68e4db0a | 35 | .PP |
cc4615cc MK |
36 | .in -4n |
37 | Feature Test Macro Requirements for glibc (see | |
38 | .BR feature_test_macros (7)): | |
39 | .in | |
68e4db0a | 40 | .PP |
cc4615cc MK |
41 | .BR sigqueue (): |
42 | _POSIX_C_SOURCE\ >=\ 199309L | |
fea681da MK |
43 | .SH DESCRIPTION |
44 | .BR sigqueue () | |
45 | sends the signal specified in | |
46 | .I sig | |
47 | to the process whose PID is given in | |
48 | .IR pid . | |
49 | The permissions required to send a signal are the same as for | |
50 | .BR kill (2). | |
c13182ef | 51 | As with |
fea681da MK |
52 | .BR kill (2), |
53 | the null signal (0) can be used to check if a process with a given | |
54 | PID exists. | |
55 | .PP | |
56 | The | |
57 | .I value | |
58 | argument is used to specify an accompanying item of data (either an integer | |
59 | or a pointer value) to be sent with the signal, and has the following type: | |
51f5698d | 60 | .PP |
088a639b | 61 | .in +4n |
bdd915e2 | 62 | .EX |
fea681da MK |
63 | union sigval { |
64 | int sival_int; | |
65 | void *sival_ptr; | |
66 | }; | |
bdd915e2 | 67 | .EE |
088a639b | 68 | .in |
847e0d88 | 69 | .PP |
fea681da MK |
70 | If the receiving process has installed a handler for this signal using the |
71 | .B SA_SIGINFO | |
72 | flag to | |
73 | .BR sigaction (2), | |
74 | then it can obtain this data via the | |
75 | .I si_value | |
c13182ef | 76 | field of the |
fea681da MK |
77 | .I siginfo_t |
78 | structure passed as the second argument to the handler. | |
79 | Furthermore, the | |
80 | .I si_code | |
81 | field of that structure will be set to | |
82 | .BR SI_QUEUE . | |
47297adb | 83 | .SH RETURN VALUE |
c13182ef | 84 | On success, |
fea681da MK |
85 | .BR sigqueue () |
86 | returns 0, indicating that the signal was successfully | |
d301ee6c | 87 | queued to the receiving process. |
2b9b829d | 88 | Otherwise, \-1 is returned and |
fea681da MK |
89 | .I errno |
90 | is set to indicate the error. | |
91 | .SH ERRORS | |
92 | .TP | |
93 | .B EAGAIN | |
94 | The limit of signals which may be queued has been reached. | |
95 | (See | |
96 | .BR signal (7) | |
97 | for further information.) | |
98 | .TP | |
99 | .B EINVAL | |
100 | .I sig | |
101 | was invalid. | |
102 | .TP | |
103 | .B EPERM | |
104 | The process does not have permission to send the signal | |
105 | to the receiving process. | |
106 | For the required permissions, see | |
107 | .BR kill (2). | |
108 | .TP | |
109 | .B ESRCH | |
110 | No process has a PID matching | |
111 | .IR pid . | |
cdd160d9 | 112 | .SH VERSIONS |
d7f69577 MK |
113 | .BR sigqueue () |
114 | and the underlying | |
115 | .BR rt_sigqueueinfo () | |
116 | system call first appeared in Linux 2.2. | |
19d5bec9 | 117 | .SH ATTRIBUTES |
32917ac0 PH |
118 | For an explanation of the terms used in this section, see |
119 | .BR attributes (7). | |
120 | .TS | |
121 | allbox; | |
122 | lb lb lb | |
123 | l l l. | |
124 | Interface Attribute Value | |
125 | T{ | |
19d5bec9 | 126 | .BR sigqueue () |
32917ac0 PH |
127 | T} Thread safety MT-Safe |
128 | .TE | |
47297adb | 129 | .SH CONFORMING TO |
0ce44b60 | 130 | POSIX.1-2001, POSIX.1-2008. |
fea681da MK |
131 | .SH NOTES |
132 | If this function results in the sending of a signal to the process | |
133 | that invoked it, and that signal was not blocked by the calling thread, | |
134 | and no other threads were willing to handle this signal (either by | |
135 | having it unblocked, or by waiting for it using | |
136 | .BR sigwait (3)), | |
137 | then at least some signal must be delivered to this thread before this | |
138 | function returns. | |
0722a578 | 139 | .SS C library/kernel differences |
4fd2f449 MK |
140 | On Linux, |
141 | .BR sigqueue () | |
142 | is implemented using the | |
5b36ada0 MK |
143 | .BR rt_sigqueueinfo (2) |
144 | system call. | |
145 | The system call differs in its third argument, which is the | |
cdd160d9 MK |
146 | .I siginfo_t |
147 | structure that will be supplied to the receiving process's | |
148 | signal handler or returned by the receiving process's | |
149 | .BR sigtimedwait (2) | |
150 | call. | |
e0bf9127 | 151 | Inside the glibc |
cdd160d9 MK |
152 | .BR sigqueue () |
153 | wrapper, this argument, | |
5b36ada0 | 154 | .IR uinfo , |
cdd160d9 | 155 | is initialized as follows: |
e646a1ba | 156 | .PP |
088a639b | 157 | .in +4n |
e646a1ba | 158 | .EX |
d2919f1e | 159 | uinfo.si_signo = sig; /* Argument supplied to sigqueue() */ |
5b36ada0 MK |
160 | uinfo.si_code = SI_QUEUE; |
161 | uinfo.si_pid = getpid(); /* Process ID of sender */ | |
162 | uinfo.si_uid = getuid(); /* Real UID of sender */ | |
d2919f1e | 163 | uinfo.si_value = val; /* Argument supplied to sigqueue() */ |
b8302363 | 164 | .EE |
cdd160d9 | 165 | .in |
47297adb | 166 | .SH SEE ALSO |
fea681da | 167 | .BR kill (2), |
d4b94904 | 168 | .BR rt_sigqueueinfo (2), |
fea681da MK |
169 | .BR sigaction (2), |
170 | .BR signal (2), | |
36757dc1 | 171 | .BR pthread_sigqueue (3), |
fea681da MK |
172 | .BR sigwait (3), |
173 | .BR signal (7) |