xref: /freebsd-14.2/lib/libc/sys/thr_exit.2 (revision 2c19e8ed)
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 May 5, 2020
32.Dt THR_EXIT 2
33.Os
34.Sh NAME
35.Nm thr_exit
36.Nd terminate current thread
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS
40.In sys/thr.h
41.Ft void
42.Fn thr_exit "long *state"
43.Sh DESCRIPTION
44.Bf -symbolic
45This function is intended for implementing threading.
46Normal applications should call
47.Xr pthread_exit 3
48instead.
49.Ef
50.Pp
51The
52.Fn thr_exit
53system call terminates the current kernel-scheduled thread.
54.Pp
55If the
56.Fa state
57argument is not
58.Dv NULL ,
59the location pointed to by the argument is
60updated with an arbitrary non-zero value, and an
61.Xr _umtx_op 2
62.Dv UMTX_OP_WAKE
63operation is consequently performed on the location.
64.Pp
65Attempts to terminate the last thread in the process are silently ignored.
66Use
67.Xr _exit 2
68syscall to terminate the process.
69.Sh RETURN VALUES
70The function does not return a value.
71A return from the function indicates that the calling thread was the
72last one in the process.
73.Sh SEE ALSO
74.Xr _exit 2 ,
75.Xr thr_kill 2 ,
76.Xr thr_kill2 2 ,
77.Xr thr_new 2 ,
78.Xr thr_self 2 ,
79.Xr thr_set_name 2 ,
80.Xr _umtx_op 2 ,
81.Xr pthread_exit 3
82.Sh STANDARDS
83The
84.Fn thr_exit
85system call is non-standard and is used by
86.Lb libthr
87to implement
88.St -p1003.1-2001
89.Xr pthread 3
90functionality.
91.Sh HISTORY
92The
93.Fn thr_exit
94system call first appeared in
95.Fx 5.2 .
96