1fc2512cfSRobert Mustacchi.\" 2fc2512cfSRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3fc2512cfSRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4fc2512cfSRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5fc2512cfSRobert Mustacchi.\" 1.0 of the CDDL. 6fc2512cfSRobert Mustacchi.\" 7fc2512cfSRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8fc2512cfSRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9fc2512cfSRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10fc2512cfSRobert Mustacchi.\" 11fc2512cfSRobert Mustacchi.\" 12fc2512cfSRobert Mustacchi.\" Copyright 2016 Joyent, Inc. 13fc2512cfSRobert Mustacchi.\" 14b77a2dc4SPeter Tribble.Dd "Aug 27, 2019" 15fc2512cfSRobert Mustacchi.Dt THRD_JOIN 3C 16fc2512cfSRobert Mustacchi.Os 17fc2512cfSRobert Mustacchi.Sh NAME 18fc2512cfSRobert Mustacchi.Nm thrd_join 19fc2512cfSRobert Mustacchi.Nd wait for thread termination 20fc2512cfSRobert Mustacchi.Sh SYNOPSIS 21fc2512cfSRobert Mustacchi.In threads.h 22fc2512cfSRobert Mustacchi.Ft int 23fc2512cfSRobert Mustacchi.Fo thrd_join 24fc2512cfSRobert Mustacchi.Fa "thrd_t thrd" 25fc2512cfSRobert Mustacchi.Fa "int *res" 26fc2512cfSRobert Mustacchi.Fc 27fc2512cfSRobert Mustacchi.Sh DESCRIPTION 28fc2512cfSRobert MustacchiThe 29fc2512cfSRobert Mustacchi.Fn thrd_join 30b77a2dc4SPeter Tribblefunction suspends the execution of the current thread and waits for the 31fc2512cfSRobert Mustacchithread indicated by 32fc2512cfSRobert Mustacchi.Fa thrd 33fc2512cfSRobert Mustacchito terminate and stores the exit status, as set by a call to 34fc2512cfSRobert Mustacchi.Xr thrd_exit 3C , 35fc2512cfSRobert Mustacchifor that thread in 36fc2512cfSRobert Mustacchi.Fa res , 37fc2512cfSRobert Mustacchiif 38fc2512cfSRobert Mustacchi.Fa res 3972d3dbb9SYuri Pankovis non-null. 4072d3dbb9SYuri PankovThe 41fc2512cfSRobert Mustacchi.Fa thrd 42fc2512cfSRobert Mustacchiargument must be a member of the current process and it cannot be 4372d3dbb9SYuri Pankovdetached. 4472d3dbb9SYuri PankovIf 45fc2512cfSRobert Mustacchi.Fa thrd 46fc2512cfSRobert Mustacchihas already terminated and another caller has not called 47fc2512cfSRobert Mustacchi.Fn thrd_join 48fc2512cfSRobert Mustacchithen the exit status will be returned to the caller without blocking 49fc2512cfSRobert Mustacchiexecution of the thread. 50fc2512cfSRobert Mustacchi.Pp 51fc2512cfSRobert MustacchiIf multiple threads call 52fc2512cfSRobert Mustacchi.Fn thrd_join 53fc2512cfSRobert Mustacchion the same thread, then both will be suspended until that thread 54fc2512cfSRobert Mustacchiterminates; however, only one thread will return successfully and obtain 55fc2512cfSRobert Mustacchithe actual status and the other will instead return with an error. 56fc2512cfSRobert Mustacchi.Pp 57fc2512cfSRobert MustacchiFor additional information on the thread joining interfaces supported by 58fc2512cfSRobert Mustacchithe system, see 59fc2512cfSRobert Mustacchi.Xr pthread_join 3C 60fc2512cfSRobert Mustacchiand 61fc2512cfSRobert Mustacchi.Xr thr_join 3C . 62b77a2dc4SPeter Tribble.Sh RETURN VALUES 63fc2512cfSRobert MustacchiUpon successful completion, the 64fc2512cfSRobert Mustacchi.Fn thrd_join 65fc2512cfSRobert Mustacchifunction returns 66fc2512cfSRobert Mustacchi.Sy thrd_success 67fc2512cfSRobert Mustacchiand if 68fc2512cfSRobert Mustacchi.Fa res 69fc2512cfSRobert Mustacchiis a non-null pointer, it will be filled in with the exit status of 70b31ca922SChris Fraire.Fa thrd . 71fc2512cfSRobert MustacchiIf an error occurs, 72fc2512cfSRobert Mustacchi.Sy thrd_error 73fc2512cfSRobert Mustacchiwill be returned. 74fc2512cfSRobert Mustacchi.Sh INTERFACE STABILITY 75fc2512cfSRobert Mustacchi.Sy Standard 76fc2512cfSRobert Mustacchi.Sh MT-LEVEL 77fc2512cfSRobert Mustacchi.Sy MT-Safe 78fc2512cfSRobert Mustacchi.Sh SEE ALSO 79fc2512cfSRobert Mustacchi.Xr pthread_join 3C , 80fc2512cfSRobert Mustacchi.Xr thrd_create 3C , 81fc2512cfSRobert Mustacchi.Xr thrd_detach 3C , 82*bbf21555SRichard Lowe.Xr attributes 7 , 83*bbf21555SRichard Lowe.Xr threads 7 84