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