xref: /freebsd-12.1/lib/libc/sys/thr_kill.2 (revision 9de9fa32)
1.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
2.\" All rights reserved.
3.\"
4.\" This documentation was written by
5.\" Konstantin Belousov <[email protected]> under sponsorship
6.\" from the FreeBSD Foundation.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\" $FreeBSD$
30.\"
31.Dd June 1, 2016
32.Dt THR_kill 2
33.Os
34.Sh NAME
35.Nm thr_kill
36.Nd send signal to thread
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS
40.In sys/thr.h
41.Ft int
42.Fn thr_kill "long id" "int sig"
43.Ft int
44.Fn thr_kill2 "pid_t pid" "long id" "int sig"
45.Sh DESCRIPTION
46The
47.Fn thr_kill
48and
49.Fn thr_kill2
50system calls allow sending a signal, specified by the
51.Fa sig
52argument, to some threads in a process.
53For the
54.Fn thr_kill
55function, signalled threads are always limited to the current process.
56For the
57.Fn thr_kill2
58function, the
59.Fa pid
60argument specifies the process with threads to be signalled.
61.Pp
62The
63.Fa id
64argument specifies which threads get the signal.
65If
66.Fa id
67is equal to \-1, all threads in the specified process are signalled.
68Otherwise, only the thread with the thread identifier equal to the
69argument is signalled.
70.Pp
71The
72.Fa sig
73argument defines the delivered signal.
74It must be a valid signal number or zero.
75In the latter case no signal is actually sent, and the call is used to
76verify the liveness of the thread.
77.Pp
78The signal is delivered with
79.Dv siginfo
80.Dv si_code
81set to
82.Dv SI_LWP .
83.Sh RETURN VALUES
84If successful,
85.Fn thr_kill
86and
87.Fn thr_kill2
88will return zero, otherwise \-1 is returned, and
89.Va errno
90is set to indicate the error.
91.Sh ERRORS
92The
93.Fn thr_kill
94and
95.Fn thr_kill2
96operations return the following errors:
97.Bl -tag -width Er
98.It Bq Er EINVAL
99The
100.Fa sig
101argument is not zero and does not specify valid signal.
102.It Bq Er ESRCH
103The specified process or thread was not found.
104.El
105.Pp
106Additionally, the
107.Fn thr_kill2
108may return the following errors:
109.Bl -tag -width Er
110.It Bq Er EPERM
111The current process does not have sufficient privilege to check existence or
112send a signal to the specified process.
113.El
114.Sh SEE ALSO
115.Xr kill 2 ,
116.Xr thr_exit 2 ,
117.Xr thr_new 2 ,
118.Xr thr_self 2 ,
119.Xr thr_set_name 2 ,
120.Xr _umtx_op 2 ,
121.Xr pthread_kill 3 ,
122.Xr signal 3
123.Sh STANDARDS
124The
125.Fn thr_kill
126and
127.Fn thr_kill2
128system calls are non-standard and are used by the
129.Lb libthr
130to implement
131.St -p1003.1-2001
132.Xr pthread 3
133functionality.
134