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