man-pages/man3/pthread_kill.3.html
2021-03-31 01:06:50 +01:00

194 lines
4.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of PTHREAD_KILL</TITLE>
</HEAD><BODY>
<H1>PTHREAD_KILL</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
pthread_kill - send a signal to a thread
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/signal.h">signal.h</A>&gt;</B>
<B>int pthread_kill(pthread_t </B><I>thread</I><B>, int </B><I>sig</I><B>);</B>
</PRE>
<P>
Compile and link with <I>-pthread</I>.
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
<B>pthread_kill</B>():
<DL COMPACT><DT id="1"><DD>
_POSIX_C_SOURCE&nbsp;&gt;=&nbsp;199506L || _XOPEN_SOURCE&nbsp;&gt;=&nbsp;500
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>pthread_kill</B>()
function sends the signal
<I>sig</I>
to
<I>thread</I>,
a thread in the same process as the caller.
The signal is asynchronously directed to
<I>thread</I>.
<P>
If
<I>sig</I>
is 0, then no signal is sent, but error checking is still performed.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success,
<B>pthread_kill</B>()
returns 0;
on error, it returns an error number, and no signal is sent.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="2"><B>EINVAL</B>
<DD>
An invalid signal was specified.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>pthread_kill</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
</TABLE>
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008.
<A NAME="lbAI">&nbsp;</A>
<H2>NOTES</H2>
Signal dispositions are process-wide:
if a signal handler is installed,
the handler will be invoked in the thread
<I>thread</I>,
but if the disposition of the signal is &quot;stop&quot;, &quot;continue&quot;, or &quot;terminate&quot;,
this action will affect the whole process.
<P>
The glibc implementation of
<B>pthread_kill</B>()
gives an error
(<B>EINVAL</B>)
on attempts to send either of the real-time signals
used internally by the NPTL threading implementation.
See
<B><A HREF="/cgi-bin/man/man2html?7+nptl">nptl</A></B>(7)
for details.
<P>
POSIX.1-2008 recommends that if an implementation detects the use
of a thread ID after the end of its lifetime,
<B>pthread_kill</B>()
should return the error
<B>ESRCH</B>.
The glibc implementation returns this error in the cases where
an invalid thread ID can be detected.
But note also that POSIX says that an attempt to use a thread ID whose
lifetime has ended produces undefined behavior,
and an attempt to use an invalid thread ID in a call to
<B>pthread_kill</B>()
can, for example, cause a segmentation fault.
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+kill">kill</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+sigaction">sigaction</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+sigpending">sigpending</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?3+pthread_self">pthread_self</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+pthread_sigmask">pthread_sigmask</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+raise">raise</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+pthreads">pthreads</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7)
<A NAME="lbAK">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="6"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="7"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="8"><A HREF="#lbAG">ATTRIBUTES</A><DD>
<DT id="9"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="10"><A HREF="#lbAI">NOTES</A><DD>
<DT id="11"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="12"><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:53 GMT, March 31, 2021
</BODY>
</HTML>