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 "Jan 13, 2015" 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. If the calling thread has not been 32detached, then the exit status information provided in 33.Fa res 34is saved and can be retrieved by the use of the 35.Xr thrd_join 3C 36function. 37.Pp 38When the thread exits, all signals will be blocked and various 39destructors and clean up handlers will be called, such as those 40registered with 41.Xr tss_create 3C . 42The act of thread termination does not cause any process-wide resources, 43such as mutexes and file descriptors to be released. 44.Pp 45If a thread, other than the thread in which 46.Fn main 47was first invoked returns from its starting routine, it will implicitly 48call 49.Fn thrd_exit 50and set the return value to be its exit status. 51.Sh RETURN VALUES 52The 53.Fn thrd_exit 54function does not return, the calling thread is terminated. 55.Sh INTERFACE STABILITY 56.Sy Standard 57.Sh MT-LEVEL 58.Sy MT-Safe 59.Sh SEE ALSO 60.Xr pthread_exit 3C , 61.Xr thr_exit 3C , 62.Xr attributes 5 , 63.Xr attributes 5 , 64.Xr threads 5 65