]>
Commit | Line | Data |
---|---|---|
abb1d278 MK |
1 | .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
abb1d278 MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
13 | .\" | |
14 | .\" Since the Linux kernel and libraries are constantly changing, this | |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
21 | .\" | |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
abb1d278 | 25 | .\" |
4b8c67d9 | 26 | .TH PTHREAD_KILL 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
abb1d278 MK |
27 | .SH NAME |
28 | pthread_kill \- send a signal to a thread | |
29 | .SH SYNOPSIS | |
30 | .nf | |
99878f27 | 31 | .B #include <signal.h> |
dbfe9c70 | 32 | .PP |
abb1d278 MK |
33 | .BI "int pthread_kill(pthread_t " thread ", int " sig ); |
34 | .fi | |
68e4db0a | 35 | .PP |
abb1d278 | 36 | Compile and link with \fI\-pthread\fP. |
68e4db0a | 37 | .PP |
d488abd6 MK |
38 | .in -4n |
39 | Feature Test Macro Requirements for glibc (see | |
40 | .BR feature_test_macros (7)): | |
41 | .in | |
68e4db0a | 42 | .PP |
d488abd6 MK |
43 | .ad l |
44 | .BR pthread_kill (): | |
45 | .RS 4 | |
46 | _POSIX_C_SOURCE\ >=\ 199506L || _XOPEN_SOURCE\ >=\ 500 | |
47 | .RE | |
48 | .ad b | |
abb1d278 MK |
49 | .SH DESCRIPTION |
50 | The | |
51 | .BR pthread_kill () | |
52 | function sends the signal | |
53 | .I sig | |
54 | to | |
55 | .IR thread , | |
34ef249e | 56 | a thread in the same process as the caller. |
abb1d278 MK |
57 | The signal is asynchronously directed to |
58 | .IR thread . | |
847e0d88 | 59 | .PP |
abb1d278 MK |
60 | If |
61 | .I sig | |
0566afc5 | 62 | is 0, then no signal is sent, but error checking is still performed. |
abb1d278 MK |
63 | .SH RETURN VALUE |
64 | On success, | |
65 | .BR pthread_kill () | |
66 | returns 0; | |
67 | on error, it returns an error number, and no signal is sent. | |
68 | .SH ERRORS | |
69 | .TP | |
27807c32 MK |
70 | .B EINVAL |
71 | An invalid signal was specified. | |
4e1cc645 | 72 | .SH ATTRIBUTES |
e094b6cc PH |
73 | For an explanation of the terms used in this section, see |
74 | .BR attributes (7). | |
75 | .TS | |
76 | allbox; | |
77 | lb lb lb | |
78 | l l l. | |
79 | Interface Attribute Value | |
80 | T{ | |
4e1cc645 | 81 | .BR pthread_kill () |
e094b6cc PH |
82 | T} Thread safety MT-Safe |
83 | .TE | |
abb1d278 | 84 | .SH CONFORMING TO |
bc17d447 | 85 | POSIX.1-2001, POSIX.1-2008. |
abb1d278 MK |
86 | .SH NOTES |
87 | Signal dispositions are process-wide: | |
88 | if a signal handler is installed, | |
89 | the handler will be invoked in the thread | |
90 | .IR thread , | |
91 | but if the disposition of the signal is "stop", "continue", or "terminate", | |
92 | this action will affect the whole process. | |
847e0d88 | 93 | .PP |
4ea239b0 MK |
94 | The glibc implementation of |
95 | .BR pthread_kill () | |
96 | gives an error | |
97 | .RB ( EINVAL ) | |
98 | on attempts to send either of the real-time signals | |
99 | used internally by the NPTL threading implementation. | |
100 | See | |
101 | .BR nptl (7) | |
102 | for details. | |
847e0d88 | 103 | .PP |
0566afc5 MK |
104 | POSIX.1-2008 recommends that if an implementation detects the use |
105 | of a thread ID after the end of its lifetime, | |
106 | .BR pthread_kill () | |
107 | should return the error | |
108 | .BR ESRCH . | |
109 | The glibc implementation returns this error in the cases where | |
110 | an invalid thread ID can be detected. | |
111 | But note also that POSIX says that an attempt to use a thread ID whose | |
112 | lifetime has ended produces undefined behavior, | |
113 | and an attempt to use an invalid thread ID in a call to | |
114 | .BR pthread_kill () | |
115 | can, for example, cause a segmentation fault. | |
abb1d278 | 116 | .SH SEE ALSO |
9c3f35c0 | 117 | .BR kill (2), |
abb1d278 MK |
118 | .BR sigaction (2), |
119 | .BR sigpending (2), | |
120 | .BR pthread_self (3), | |
121 | .BR pthread_sigmask (3), | |
122 | .BR raise (3), | |
123 | .BR pthreads (7), | |
124 | .BR signal (7) |