mount_setattr.2: Minor tweaks to Christian's patch
[man-pages.git] / man3 / pthread_kill.3
blobea1d7eaed652c442c84a1b3bdea079751d71e547
1 .\" Copyright (c) 2009 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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.
24 .\" %%%LICENSE_END
25 .\"
26 .TH PTHREAD_KILL 3 2021-03-22 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 pthread_kill \- send a signal to a thread
29 .SH SYNOPSIS
30 .nf
31 .B #include <signal.h>
32 .PP
33 .BI "int pthread_kill(pthread_t " thread ", int " sig );
34 .fi
35 .PP
36 Compile and link with \fI\-pthread\fP.
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 pthread_kill ():
44 .nf
45     _POSIX_C_SOURCE >= 199506L || _XOPEN_SOURCE >= 500
46 .fi
47 .SH DESCRIPTION
48 The
49 .BR pthread_kill ()
50 function sends the signal
51 .I sig
53 .IR thread ,
54 a thread in the same process as the caller.
55 The signal is asynchronously directed to
56 .IR thread .
57 .PP
59 .I sig
60 is 0, then no signal is sent, but error checking is still performed.
61 .SH RETURN VALUE
62 On success,
63 .BR pthread_kill ()
64 returns 0;
65 on error, it returns an error number, and no signal is sent.
66 .SH ERRORS
67 .TP
68 .B EINVAL
69 An invalid signal was specified.
70 .SH ATTRIBUTES
71 For an explanation of the terms used in this section, see
72 .BR attributes (7).
73 .ad l
74 .nh
75 .TS
76 allbox;
77 lbx lb lb
78 l l l.
79 Interface       Attribute       Value
81 .BR pthread_kill ()
82 T}      Thread safety   MT-Safe
83 .TE
84 .hy
85 .ad
86 .sp 1
87 .SH CONFORMING TO
88 POSIX.1-2001, POSIX.1-2008.
89 .SH NOTES
90 Signal dispositions are process-wide:
91 if a signal handler is installed,
92 the handler will be invoked in the thread
93 .IR thread ,
94 but if the disposition of the signal is "stop", "continue", or "terminate",
95 this action will affect the whole process.
96 .PP
97 The glibc implementation of
98 .BR pthread_kill ()
99 gives an error
100 .RB ( EINVAL )
101 on attempts to send either of the real-time signals
102 used internally by the NPTL threading implementation.
104 .BR nptl (7)
105 for details.
107 POSIX.1-2008 recommends that if an implementation detects the use
108 of a thread ID after the end of its lifetime,
109 .BR pthread_kill ()
110 should return the error
111 .BR ESRCH .
112 The glibc implementation returns this error in the cases where
113 an invalid thread ID can be detected.
114 But note also that POSIX says that an attempt to use a thread ID whose
115 lifetime has ended produces undefined behavior,
116 and an attempt to use an invalid thread ID in a call to
117 .BR pthread_kill ()
118 can, for example, cause a segmentation fault.
119 .SH SEE ALSO
120 .BR kill (2),
121 .BR sigaction (2),
122 .BR sigpending (2),
123 .BR pthread_self (3),
124 .BR pthread_sigmask (3),
125 .BR raise (3),
126 .BR pthreads (7),
127 .BR signal (7)