ipc.2: Add needed include
[man-pages.git] / man3 / sigqueue.3
blob1a916c4287741ab31e056919ce7fb347250a4c6f
1 .\" Copyright (c) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" added note on self-signaling, aeb, 2002-06-07
26 .\" added note on CAP_KILL, mtk, 2004-06-16
27 .\"
28 .TH SIGQUEUE 3 2021-03-22 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 sigqueue \- queue a signal and data to a process
31 .SH SYNOPSIS
32 .nf
33 .B #include <signal.h>
34 .PP
35 .BI "int sigqueue(pid_t " pid ", int " sig ", const union sigval " value );
36 .fi
37 .PP
38 .RS -4
39 Feature Test Macro Requirements for glibc (see
40 .BR feature_test_macros (7)):
41 .RE
42 .PP
43 .BR sigqueue ():
44 .nf
45     _POSIX_C_SOURCE >= 199309L
46 .fi
47 .SH DESCRIPTION
48 .BR sigqueue ()
49 sends the signal specified in
50 .I sig
51 to the process whose PID is given in
52 .IR pid .
53 The permissions required to send a signal are the same as for
54 .BR kill (2).
55 As with
56 .BR kill (2),
57 the null signal (0) can be used to check if a process with a given
58 PID exists.
59 .PP
60 The
61 .I value
62 argument is used to specify an accompanying item of data (either an integer
63 or a pointer value) to be sent with the signal, and has the following type:
64 .PP
65 .in +4n
66 .EX
67 union sigval {
68     int   sival_int;
69     void *sival_ptr;
71 .EE
72 .in
73 .PP
74 If the receiving process has installed a handler for this signal using the
75 .B SA_SIGINFO
76 flag to
77 .BR sigaction (2),
78 then it can obtain this data via the
79 .I si_value
80 field of the
81 .I siginfo_t
82 structure passed as the second argument to the handler.
83 Furthermore, the
84 .I si_code
85 field of that structure will be set to
86 .BR SI_QUEUE .
87 .SH RETURN VALUE
88 On success,
89 .BR sigqueue ()
90 returns 0, indicating that the signal was successfully
91 queued to the receiving process.
92 Otherwise, \-1 is returned and
93 .I errno
94 is set to indicate the error.
95 .SH ERRORS
96 .TP
97 .B EAGAIN
98 The limit of signals which may be queued has been reached.
99 (See
100 .BR signal (7)
101 for further information.)
103 .B EINVAL
104 .I sig
105 was invalid.
107 .B EPERM
108 The process does not have permission to send the signal
109 to the receiving process.
110 For the required permissions, see
111 .BR kill (2).
113 .B ESRCH
114 No process has a PID matching
115 .IR pid .
116 .SH VERSIONS
117 .BR sigqueue ()
118 and the underlying
119 .BR rt_sigqueueinfo ()
120 system call first appeared in Linux 2.2.
121 .SH ATTRIBUTES
122 For an explanation of the terms used in this section, see
123 .BR attributes (7).
124 .ad l
127 allbox;
128 lbx lb lb
129 l l l.
130 Interface       Attribute       Value
132 .BR sigqueue ()
133 T}      Thread safety   MT-Safe
137 .sp 1
138 .SH CONFORMING TO
139 POSIX.1-2001, POSIX.1-2008.
140 .SH NOTES
141 If this function results in the sending of a signal to the process
142 that invoked it, and that signal was not blocked by the calling thread,
143 and no other threads were willing to handle this signal (either by
144 having it unblocked, or by waiting for it using
145 .BR sigwait (3)),
146 then at least some signal must be delivered to this thread before this
147 function returns.
148 .SS C library/kernel differences
149 On Linux,
150 .BR sigqueue ()
151 is implemented using the
152 .BR rt_sigqueueinfo (2)
153 system call.
154 The system call differs in its third argument, which is the
155 .I siginfo_t
156 structure that will be supplied to the receiving process's
157 signal handler or returned by the receiving process's
158 .BR sigtimedwait (2)
159 call.
160 Inside the glibc
161 .BR sigqueue ()
162 wrapper, this argument,
163 .IR uinfo ,
164 is initialized as follows:
166 .in +4n
168 uinfo.si_signo = sig;      /* Argument supplied to sigqueue() */
169 uinfo.si_code = SI_QUEUE;
170 uinfo.si_pid = getpid();   /* Process ID of sender */
171 uinfo.si_uid = getuid();   /* Real UID of sender */
172 uinfo.si_value = val;      /* Argument supplied to sigqueue() */
175 .SH SEE ALSO
176 .BR kill (2),
177 .BR rt_sigqueueinfo (2),
178 .BR sigaction (2),
179 .BR signal (2),
180 .BR pthread_sigqueue (3),
181 .BR sigwait (3),
182 .BR signal (7)