]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
abb1d278 MK |
2 | .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
4 | .\" | |
5fbde956 | 5 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
abb1d278 | 6 | .\" |
4c1c5274 | 7 | .TH pthread_kill 3 (date) "Linux man-pages (unreleased)" |
abb1d278 MK |
8 | .SH NAME |
9 | pthread_kill \- send a signal to a thread | |
29a94159 AC |
10 | .SH LIBRARY |
11 | POSIX threads library | |
8fc3b2cf | 12 | .RI ( libpthread ", " \-lpthread ) |
abb1d278 MK |
13 | .SH SYNOPSIS |
14 | .nf | |
99878f27 | 15 | .B #include <signal.h> |
dbfe9c70 | 16 | .PP |
abb1d278 MK |
17 | .BI "int pthread_kill(pthread_t " thread ", int " sig ); |
18 | .fi | |
68e4db0a | 19 | .PP |
d39ad78f | 20 | .RS -4 |
d488abd6 MK |
21 | Feature Test Macro Requirements for glibc (see |
22 | .BR feature_test_macros (7)): | |
d39ad78f | 23 | .RE |
68e4db0a | 24 | .PP |
d488abd6 | 25 | .BR pthread_kill (): |
9d2adbae | 26 | .nf |
5c10d2c5 | 27 | _POSIX_C_SOURCE >= 199506L || _XOPEN_SOURCE >= 500 |
9d2adbae | 28 | .fi |
abb1d278 MK |
29 | .SH DESCRIPTION |
30 | The | |
31 | .BR pthread_kill () | |
32 | function sends the signal | |
33 | .I sig | |
34 | to | |
35 | .IR thread , | |
34ef249e | 36 | a thread in the same process as the caller. |
abb1d278 MK |
37 | The signal is asynchronously directed to |
38 | .IR thread . | |
847e0d88 | 39 | .PP |
abb1d278 MK |
40 | If |
41 | .I sig | |
0566afc5 | 42 | is 0, then no signal is sent, but error checking is still performed. |
abb1d278 MK |
43 | .SH RETURN VALUE |
44 | On success, | |
45 | .BR pthread_kill () | |
46 | returns 0; | |
47 | on error, it returns an error number, and no signal is sent. | |
48 | .SH ERRORS | |
49 | .TP | |
27807c32 MK |
50 | .B EINVAL |
51 | An invalid signal was specified. | |
4e1cc645 | 52 | .SH ATTRIBUTES |
e094b6cc PH |
53 | For an explanation of the terms used in this section, see |
54 | .BR attributes (7). | |
55 | .TS | |
56 | allbox; | |
c466875e | 57 | lbx lb lb |
e094b6cc PH |
58 | l l l. |
59 | Interface Attribute Value | |
60 | T{ | |
9e54434e BR |
61 | .na |
62 | .nh | |
4e1cc645 | 63 | .BR pthread_kill () |
e094b6cc PH |
64 | T} Thread safety MT-Safe |
65 | .TE | |
c466875e | 66 | .sp 1 |
4131356c | 67 | .SH VERSIONS |
4ea239b0 MK |
68 | The glibc implementation of |
69 | .BR pthread_kill () | |
70 | gives an error | |
71 | .RB ( EINVAL ) | |
72 | on attempts to send either of the real-time signals | |
73 | used internally by the NPTL threading implementation. | |
74 | See | |
75 | .BR nptl (7) | |
76 | for details. | |
847e0d88 | 77 | .PP |
0566afc5 MK |
78 | POSIX.1-2008 recommends that if an implementation detects the use |
79 | of a thread ID after the end of its lifetime, | |
80 | .BR pthread_kill () | |
81 | should return the error | |
82 | .BR ESRCH . | |
83 | The glibc implementation returns this error in the cases where | |
84 | an invalid thread ID can be detected. | |
85 | But note also that POSIX says that an attempt to use a thread ID whose | |
86 | lifetime has ended produces undefined behavior, | |
87 | and an attempt to use an invalid thread ID in a call to | |
88 | .BR pthread_kill () | |
89 | can, for example, cause a segmentation fault. | |
4131356c AC |
90 | .SH STANDARDS |
91 | POSIX.1-2008. | |
92 | .SH HISTORY | |
93 | POSIX.1-2001. | |
94 | .SH NOTES | |
95 | Signal dispositions are process-wide: | |
96 | if a signal handler is installed, | |
97 | the handler will be invoked in the thread | |
98 | .IR thread , | |
99 | but if the disposition of the signal is "stop", "continue", or "terminate", | |
100 | this action will affect the whole process. | |
abb1d278 | 101 | .SH SEE ALSO |
9c3f35c0 | 102 | .BR kill (2), |
abb1d278 MK |
103 | .BR sigaction (2), |
104 | .BR sigpending (2), | |
105 | .BR pthread_self (3), | |
106 | .BR pthread_sigmask (3), | |
107 | .BR raise (3), | |
108 | .BR pthreads (7), | |
109 | .BR signal (7) |