]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_kill.3
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man3 / pthread_kill.3
CommitLineData
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
28pthread_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 36Compile and link with \fI\-pthread\fP.
68e4db0a 37.PP
d488abd6
MK
38.in -4n
39Feature 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
50The
51.BR pthread_kill ()
52function sends the signal
53.I sig
54to
55.IR thread ,
34ef249e 56a thread in the same process as the caller.
abb1d278
MK
57The signal is asynchronously directed to
58.IR thread .
847e0d88 59.PP
abb1d278
MK
60If
61.I sig
0566afc5 62is 0, then no signal is sent, but error checking is still performed.
abb1d278
MK
63.SH RETURN VALUE
64On success,
65.BR pthread_kill ()
66returns 0;
67on error, it returns an error number, and no signal is sent.
68.SH ERRORS
69.TP
27807c32
MK
70.B EINVAL
71An invalid signal was specified.
4e1cc645 72.SH ATTRIBUTES
e094b6cc
PH
73For an explanation of the terms used in this section, see
74.BR attributes (7).
75.TS
76allbox;
77lb lb lb
78l l l.
79Interface Attribute Value
80T{
4e1cc645 81.BR pthread_kill ()
e094b6cc
PH
82T} Thread safety MT-Safe
83.TE
abb1d278 84.SH CONFORMING TO
bc17d447 85POSIX.1-2001, POSIX.1-2008.
abb1d278
MK
86.SH NOTES
87Signal dispositions are process-wide:
88if a signal handler is installed,
89the handler will be invoked in the thread
90.IR thread ,
91but if the disposition of the signal is "stop", "continue", or "terminate",
92this action will affect the whole process.
847e0d88 93.PP
4ea239b0
MK
94The glibc implementation of
95.BR pthread_kill ()
96gives an error
97.RB ( EINVAL )
98on attempts to send either of the real-time signals
99used internally by the NPTL threading implementation.
100See
101.BR nptl (7)
102for details.
847e0d88 103.PP
0566afc5
MK
104POSIX.1-2008 recommends that if an implementation detects the use
105of a thread ID after the end of its lifetime,
106.BR pthread_kill ()
107should return the error
108.BR ESRCH .
109The glibc implementation returns this error in the cases where
110an invalid thread ID can be detected.
111But note also that POSIX says that an attempt to use a thread ID whose
112lifetime has ended produces undefined behavior,
113and an attempt to use an invalid thread ID in a call to
114.BR pthread_kill ()
115can, 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)