1PTHREAD_KILL(3)            Linux Programmer's Manual           PTHREAD_KILL(3)
2
3
4

NAME

6       pthread_kill - send a signal to a thread
7

SYNOPSIS

9       #include <signal.h>
10
11       int pthread_kill(pthread_t thread, int sig);
12
13       Compile and link with -pthread.
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       pthread_kill():
18           _POSIX_C_SOURCE >= 199506L || _XOPEN_SOURCE >= 500
19

DESCRIPTION

21       The pthread_kill() function sends the signal sig to thread, a thread in
22       the same process as the caller.  The signal is asynchronously  directed
23       to thread.
24
25       If  sig  is 0, then no signal is sent, but error checking is still per‐
26       formed.
27

RETURN VALUE

29       On success, pthread_kill() returns 0; on error,  it  returns  an  error
30       number, and no signal is sent.
31

ERRORS

33       EINVAL An invalid signal was specified.
34

ATTRIBUTES

36       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
37       tributes(7).
38
39       ┌────────────────────────────────────────────┬───────────────┬─────────┐
40Interface                                   Attribute     Value   
41       ├────────────────────────────────────────────┼───────────────┼─────────┤
42pthread_kill()                              │ Thread safety │ MT-Safe │
43       └────────────────────────────────────────────┴───────────────┴─────────┘
44

CONFORMING TO

46       POSIX.1-2001, POSIX.1-2008.
47

NOTES

49       Signal dispositions are process-wide: if a signal handler is installed,
50       the  handler  will be invoked in the thread thread, but if the disposi‐
51       tion of the signal is "stop", "continue", or "terminate",  this  action
52       will affect the whole process.
53
54       The  glibc  implementation of pthread_kill() gives an error (EINVAL) on
55       attempts to send either of the real-time signals used internally by the
56       NPTL threading implementation.  See nptl(7) for details.
57
58       POSIX.1-2008  recommends that if an implementation detects the use of a
59       thread ID after the end of its lifetime, pthread_kill()  should  return
60       the  error  ESRCH.   The glibc implementation returns this error in the
61       cases where an invalid thread ID can be detected.  But note  also  that
62       POSIX  says that an attempt to use a thread ID whose lifetime has ended
63       produces undefined behavior, and an attempt to use an invalid thread ID
64       in  a  call  to  pthread_kill()  can, for example, cause a segmentation
65       fault.
66

SEE ALSO

68       kill(2),  sigaction(2),  sigpending(2),  pthread_self(3),  pthread_sig‐
69       mask(3), raise(3), pthreads(7), signal(7)
70

COLOPHON

72       This  page  is  part of release 5.13 of the Linux man-pages project.  A
73       description of the project, information about reporting bugs,  and  the
74       latest     version     of     this    page,    can    be    found    at
75       https://www.kernel.org/doc/man-pages/.
76
77
78
79Linux                             2021-03-22                   PTHREAD_KILL(3)
Impressum