OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_kill.3
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 2014-05-13 "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
33 .BI "int pthread_kill(pthread_t " thread ", int " sig );
34 .fi
35 .sp
36 Compile and link with \fI\-pthread\fP.
37 .sp
38 .in -4n
39 Feature Test Macro Requirements for glibc (see
40 .BR feature_test_macros (7)):
41 .in
42 .sp
43 .ad l
44 .BR pthread_kill ():
45 .RS 4
46 _POSIX_C_SOURCE\ >=\ 199506L || _XOPEN_SOURCE\ >=\ 500
47 .RE
48 .ad b
49 .SH DESCRIPTION
50 The
51 .BR pthread_kill ()
52 function sends the signal
53 .I sig
54 to
55 .IR thread ,
56 a thread in the same process as the caller.
57 The signal is asynchronously directed to
58 .IR thread .
59
60 If
61 .I sig
62 is 0, then no signal is sent, but error checking is still performed.
63 .SH RETURN VALUE
64 On success,
65 .BR pthread_kill ()
66 returns 0;
67 on error, it returns an error number, and no signal is sent.
68 .SH ERRORS
69 .TP
70 .B EINVAL
71 An invalid signal was specified.
72 .SH ATTRIBUTES
73 .SS Multithreading (see pthreads(7))
74 The
75 .BR pthread_kill ()
76 function is thread-safe.
77 .SH CONFORMING TO
78 POSIX.1-2008.
79 .SH NOTES
80 Signal dispositions are process-wide:
81 if a signal handler is installed,
82 the handler will be invoked in the thread
83 .IR thread ,
84 but if the disposition of the signal is "stop", "continue", or "terminate",
85 this action will affect the whole process.
86
87 POSIX.1-2008 recommends that if an implementation detects the use
88 of a thread ID after the end of its lifetime,
89 .BR pthread_kill ()
90 should return the error
91 .BR ESRCH .
92 The glibc implementation returns this error in the cases where
93 an invalid thread ID can be detected.
94 But note also that POSIX says that an attempt to use a thread ID whose
95 lifetime has ended produces undefined behavior,
96 and an attempt to use an invalid thread ID in a call to
97 .BR pthread_kill ()
98 can, for example, cause a segmentation fault.
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)
108 .SH COLOPHON
109 This page is part of release 3.79 of the Linux
110 .I man-pages
111 project.
112 A description of the project,
113 information about reporting bugs,
114 and the latest version of this page,
115 can be found at
116 \%http://www.kernel.org/doc/man\-pages/.