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 "Aug 27, 2019" 15.Dt THRD_JOIN 3C 16.Os 17.Sh NAME 18.Nm thrd_join 19.Nd wait for thread termination 20.Sh SYNOPSIS 21.In threads.h 22.Ft int 23.Fo thrd_join 24.Fa "thrd_t thrd" 25.Fa "int *res" 26.Fc 27.Sh DESCRIPTION 28The 29.Fn thrd_join 30function suspends the execution of the current thread and waits for the 31thread indicated by 32.Fa thrd 33to terminate and stores the exit status, as set by a call to 34.Xr thrd_exit 3C , 35for that thread in 36.Fa res , 37if 38.Fa res 39is non-null. 40The 41.Fa thrd 42argument must be a member of the current process and it cannot be 43detached. 44If 45.Fa thrd 46has already terminated and another caller has not called 47.Fn thrd_join 48then the exit status will be returned to the caller without blocking 49execution of the thread. 50.Pp 51If multiple threads call 52.Fn thrd_join 53on the same thread, then both will be suspended until that thread 54terminates; however, only one thread will return successfully and obtain 55the actual status and the other will instead return with an error. 56.Pp 57For additional information on the thread joining interfaces supported by 58the system, see 59.Xr pthread_join 3C 60and 61.Xr thr_join 3C . 62.Sh RETURN VALUES 63Upon successful completion, the 64.Fn thrd_join 65function returns 66.Sy thrd_success 67and if 68.Fa res 69is a non-null pointer, it will be filled in with the exit status of 70.Fa thrd . 71If an error occurs, 72.Sy thrd_error 73will be returned. 74.Sh INTERFACE STABILITY 75.Sy Standard 76.Sh MT-LEVEL 77.Sy MT-Safe 78.Sh SEE ALSO 79.Xr pthread_join 3C , 80.Xr thrd_create 3C , 81.Xr thrd_detach 3C , 82.Xr attributes 5 , 83.Xr threads 5 84