Debian Codegraph @

upstream/debian-unstable/man3/pthread_kill.3

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