Debian Codegraph @

upstream/debian-unstable/man3/sigqueue.3

raw
1 '\" t
2 .\" Copyright 2002, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH sigqueue 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 sigqueue \- queue a signal and data to a process
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <signal.h>
16 .P
17 .BI "int sigqueue(pid_t " pid ", int " sig ", const union sigval " value );
18 .fi
19 .P
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .P
25 .BR sigqueue ():
26 .nf
27 _POSIX_C_SOURCE >= 199309L
28 .fi
29 .SH DESCRIPTION
30 .BR sigqueue ()
31 sends the signal specified in
32 .I sig
33 to the process whose PID is given in
34 .IR pid .
35 The permissions required to send a signal are the same as for
36 .BR kill (2).
37 As with
38 .BR kill (2),
39 the null signal (0) can be used to check if a process with a given
40 PID exists.
41 .P
42 The
43 .I value
44 argument is used to specify an accompanying item of data (either an integer
45 or a pointer value) to be sent with the signal, and has the following type:
46 .P
47 .in +4n
48 .EX
49 union sigval {
50 int sival_int;
51 void *sival_ptr;
52 };
53 .EE
54 .in
55 .P
56 If the receiving process has installed a handler for this signal using the
57 .B SA_SIGINFO
58 flag to
59 .BR sigaction (2),
60 then it can obtain this data via the
61 .I si_value
62 field of the
63 .I siginfo_t
64 structure passed as the second argument to the handler.
65 Furthermore, the
66 .I si_code
67 field of that structure will be set to
68 .BR SI_QUEUE .
69 .SH RETURN VALUE
70 On success,
71 .BR sigqueue ()
72 returns 0, indicating that the signal was successfully
73 queued to the receiving process.
74 Otherwise, \-1 is returned and
75 .I errno
76 is set to indicate the error.
77 .SH ERRORS
78 .TP
79 .B EAGAIN
80 The limit of signals which may be queued has been reached.
81 (See
82 .BR signal (7)
83 for further information.)
84 .TP
85 .B EINVAL
86 .I sig
87 was invalid.
88 .TP
89 .B EPERM
90 The process does not have permission to send the signal
91 to the receiving process.
92 For the required permissions, see
93 .BR kill (2).
94 .TP
95 .B ESRCH
96 No process has a PID matching
97 .IR pid .
98 .SH ATTRIBUTES
99 For an explanation of the terms used in this section, see
100 .BR attributes (7).
101 .TS
102 allbox;
103 lbx lb lb
104 l l l.
105 Interface Attribute Value
106 T{
107 .na
108 .nh
109 .BR sigqueue ()
110 T} Thread safety MT-Safe
111 .TE
112 .SH VERSIONS
113 .SS C library/kernel differences
114 On Linux,
115 .BR sigqueue ()
116 is implemented using the
117 .BR rt_sigqueueinfo (2)
118 system call.
119 The system call differs in its third argument, which is the
120 .I siginfo_t
121 structure that will be supplied to the receiving process's
122 signal handler or returned by the receiving process's
123 .BR sigtimedwait (2)
124 call.
125 Inside the glibc
126 .BR sigqueue ()
127 wrapper, this argument,
128 .IR uinfo ,
129 is initialized as follows:
130 .P
131 .in +4n
132 .EX
133 uinfo.si_signo = sig; /* Argument supplied to sigqueue() */
134 uinfo.si_code = SI_QUEUE;
135 uinfo.si_pid = getpid(); /* Process ID of sender */
136 uinfo.si_uid = getuid(); /* Real UID of sender */
137 uinfo.si_value = val; /* Argument supplied to sigqueue() */
138 .EE
139 .in
140 .SH STANDARDS
141 POSIX.1-2008.
142 .SH HISTORY
143 Linux 2.2.
144 POSIX.1-2001.
145 .SH NOTES
146 If this function results in the sending of a signal to the process
147 that invoked it, and that signal was not blocked by the calling thread,
148 and no other threads were willing to handle this signal (either by
149 having it unblocked, or by waiting for it using
150 .BR sigwait (3)),
151 then at least some signal must be delivered to this thread before this
152 function returns.
153 .SH SEE ALSO
154 .BR kill (2),
155 .BR rt_sigqueueinfo (2),
156 .BR sigaction (2),
157 .BR signal (2),
158 .BR pthread_sigqueue (3),
159 .BR sigwait (3),
160 .BR signal (7)