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
37       attributes(7).
38
39       ┌───────────────┬───────────────┬─────────┐
40Interface      Attribute     Value   
41       ├───────────────┼───────────────┼─────────┤
42pthread_kill() │ Thread safety │ MT-Safe │
43       └───────────────┴───────────────┴─────────┘

CONFORMING TO

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

NOTES

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

SEE ALSO

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

COLOPHON

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