1pthread_kill(3)            Library Functions Manual            pthread_kill(3)
2
3
4

NAME

6       pthread_kill - send a signal to a thread
7

LIBRARY

9       POSIX threads library (libpthread, -lpthread)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

34       EINVAL An invalid signal was specified.
35

ATTRIBUTES

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

VERSIONS

47       The glibc implementation of pthread_kill() gives an error  (EINVAL)  on
48       attempts to send either of the real-time signals used internally by the
49       NPTL threading implementation.  See nptl(7) for details.
50
51       POSIX.1-2008 recommends that if an implementation detects the use of  a
52       thread  ID  after the end of its lifetime, pthread_kill() should return
53       the error ESRCH.  The glibc implementation returns this  error  in  the
54       cases  where  an invalid thread ID can be detected.  But note also that
55       POSIX says that an attempt to use a thread ID whose lifetime has  ended
56       produces undefined behavior, and an attempt to use an invalid thread ID
57       in a call to pthread_kill() can,  for  example,  cause  a  segmentation
58       fault.
59

STANDARDS

61       POSIX.1-2008.
62

HISTORY

64       POSIX.1-2001.
65

NOTES

67       Signal dispositions are process-wide: if a signal handler is installed,
68       the handler will be invoked in the thread thread, but if  the  disposi‐
69       tion  of  the signal is "stop", "continue", or "terminate", this action
70       will affect the whole process.
71

SEE ALSO

73       kill(2),  sigaction(2),  sigpending(2),  pthread_self(3),  pthread_sig‐
74       mask(3), raise(3), pthreads(7), signal(7)
75
76
77
78Linux man-pages 6.04              2023-03-30                   pthread_kill(3)
Impressum