1PTHREAD_KILL(3P) POSIX Programmer's Manual PTHREAD_KILL(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 pthread_kill — send a signal to a thread
13
15 #include <signal.h>
16
17 int pthread_kill(pthread_t thread, int sig);
18
20 The pthread_kill() function shall request that a signal be delivered to
21 the specified thread.
22
23 As in kill(), if sig is zero, error checking shall be performed but no
24 signal shall actually be sent.
25
27 Upon successful completion, the function shall return a value of zero.
28 Otherwise, the function shall return an error number. If the
29 pthread_kill() function fails, no signal shall be sent.
30
32 The pthread_kill() function shall fail if:
33
34 EINVAL The value of the sig argument is an invalid or unsupported sig‐
35 nal number.
36
37 The pthread_kill() function shall not return an error code of [EINTR].
38
39 The following sections are informative.
40
42 None.
43
45 The pthread_kill() function provides a mechanism for asynchronously
46 directing a signal at a thread in the calling process. This could be
47 used, for example, by one thread to affect broadcast delivery of a sig‐
48 nal to a set of threads.
49
50 Note that pthread_kill() only causes the signal to be handled in the
51 context of the given thread; the signal action (termination or stop‐
52 ping) affects the process as a whole.
53
55 If an implementation detects use of a thread ID after the end of its
56 lifetime, it is recommended that the function should fail and report an
57 [ESRCH] error.
58
59 Existing implementations vary on the result of a pthread_kill() with a
60 thread ID indicating an inactive thread (a terminated thread that has
61 not been detached or joined). Some indicate success on such a call,
62 while others give an error of [ESRCH]. Since the definition of thread
63 lifetime in this volume of POSIX.1‐2017 covers inactive threads, the
64 [ESRCH] error as described is inappropriate in this case. In particu‐
65 lar, this means that an application cannot have one thread check for
66 termination of another with pthread_kill().
67
69 A future version of this standard may require that pthread_kill() not
70 fail with [ESRCH] in the case of sending signals to an inactive thread
71 (a terminated thread not yet detached or joined), even though no signal
72 will be delivered because the thread is no longer running.
73
75 kill(), pthread_self(), raise()
76
77 The Base Definitions volume of POSIX.1‐2017, <signal.h>
78
80 Portions of this text are reprinted and reproduced in electronic form
81 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
82 table Operating System Interface (POSIX), The Open Group Base Specifi‐
83 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
84 Electrical and Electronics Engineers, Inc and The Open Group. In the
85 event of any discrepancy between this version and the original IEEE and
86 The Open Group Standard, the original IEEE and The Open Group Standard
87 is the referee document. The original Standard can be obtained online
88 at http://www.opengroup.org/unix/online.html .
89
90 Any typographical or formatting errors that appear in this page are
91 most likely to have been introduced during the conversion of the source
92 files to man page format. To report such errors, see https://www.ker‐
93 nel.org/doc/man-pages/reporting_bugs.html .
94
95
96
97IEEE/The Open Group 2017 PTHREAD_KILL(3P)