OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man3 / sigqueue.3
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 2013-12-16 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 sigqueue \- queue a signal and data to a process
31 .SH SYNOPSIS
32 .B #include <signal.h>
33 .sp
34 .BI "int sigqueue(pid_t " pid ", int " sig ", const union sigval " value );
35 .sp
36 .in -4n
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .in
40 .sp
41 .BR sigqueue ():
42 _POSIX_C_SOURCE\ >=\ 199309L
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).
51 As with
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:
60 .sp
61 .in +4n
62 .nf
63 union sigval {
64     int   sival_int;
65     void *sival_ptr;
66 };
67 .fi
68 .in
69
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
76 field of the
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 .
83 .SH RETURN VALUE
84 On success,
85 .BR sigqueue ()
86 returns 0, indicating that the signal was successfully
87 queued to the receiving process.
88 Otherwise, \-1 is returned and
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 .
112 .SH VERSIONS
113 This system call first appeared in Linux 2.2.
114 .SH ATTRIBUTES
115 .SS Multithreading (see pthreads(7))
116 The
117 .BR sigqueue ()
118 function is thread-safe.
119 .SH CONFORMING TO
120 POSIX.1-2001.
121 .SH NOTES
122 If this function results in the sending of a signal to the process
123 that invoked it, and that signal was not blocked by the calling thread,
124 and no other threads were willing to handle this signal (either by
125 having it unblocked, or by waiting for it using
126 .BR sigwait (3)),
127 then at least some signal must be delivered to this thread before this
128 function returns.
129
130 On Linux, this function is implemented using the
131 .BR rt_sigqueueinfo (2)
132 system call.
133 The system call differs in its third argument, which is the
134 .I siginfo_t
135 structure that will be supplied to the receiving process's
136 signal handler or returned by the receiving process's
137 .BR sigtimedwait (2)
138 call.
139 Inside the glibc
140 .BR sigqueue ()
141 wrapper, this argument,
142 .IR uinfo ,
143 is initialized as follows:
144 .in +4n
145 .nf
146
147 uinfo.si_signo = sig;      /* Argument supplied to sigqueue() */
148 uinfo.si_code = SI_QUEUE;
149 uinfo.si_pid = getpid();   /* Process ID of sender */
150 uinfo.si_uid = getuid();   /* Real UID of sender */
151 uinfo.si_value = val;      /* Argument supplied to sigqueue() */
152 .fi
153 .in
154 .SH SEE ALSO
155 .BR kill (2),
156 .BR rt_sigqueueinfo (2),
157 .BR sigaction (2),
158 .BR signal (2),
159 .BR pthread_sigqueue (3),
160 .BR sigwait (3),
161 .BR signal (7)
162 .SH COLOPHON
163 This page is part of release 3.79 of the Linux
164 .I man-pages
165 project.
166 A description of the project,
167 information about reporting bugs,
168 and the latest version of this page,
169 can be found at
170 \%http://www.kernel.org/doc/man\-pages/.