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