xref: /illumos-gate/usr/src/man/man3c/thrd_exit.3c (revision 82079dec87a9b623b65337b7422dc7c27a04f0d9)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2016 Joyent, Inc.
13.\"
14.Dd "February 21, 2023"
15.Dt THRD_EXIT 3C
16.Os
17.Sh NAME
18.Nm thrd_exit
19.Nd terminate a thread
20.Sh SYNOPSIS
21.In threads.h
22.Ft "_Noreturn void"
23.Fo thrd_exit
24.Fa "int res"
25.Fc
26.Sh DESCRIPTION
27The
28.Fn thrd_exit
29function terminates the calling thread, in a similar way that
30.Xr exit 3C
31terminates the calling process.
32If the calling thread has not been detached, then the exit status information
33provided in
34.Fa res
35is saved and can be retrieved by the use of the
36.Xr thrd_join 3C
37function.
38.Pp
39When the thread exits, all signals will be blocked and various
40destructors and clean up handlers will be called, such as those
41registered with
42.Xr tss_create 3C .
43The act of thread termination does not cause any process-wide resources,
44such as mutexes and file descriptors to be released.
45.Pp
46If a thread, other than the thread in which
47.Fn main
48was first invoked returns from its starting routine, it will implicitly
49call
50.Fn thrd_exit
51and set the return value to be its exit status.
52.Sh RETURN VALUES
53The
54.Fn thrd_exit
55function does not return, the calling thread is terminated.
56.Sh INTERFACE STABILITY
57.Sy Standard
58.Sh MT-LEVEL
59.Sy MT-Safe
60.Sh SEE ALSO
61.Xr pthread_exit 3C ,
62.Xr thr_exit 3C ,
63.Xr attributes 7 ,
64.Xr threads 7
65