xref: /illumos-gate/usr/src/man/man3c/thrd_join.3c (revision 56350fe51602d105c19353b8bf580ddd591726d5)
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_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 exection 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. The
40.Fa thrd
41argument must be a member of the current process and it cannot be
42detached. If
43.Fa thrd
44has already terminated and another caller has not called
45.Fn thrd_join
46then the exit status will be returned to the caller without blocking
47execution of the thread.
48.Pp
49If multiple threads call
50.Fn thrd_join
51on the same thread, then both will be suspended until that thread
52terminates; however, only one thread will return successfully and obtain
53the actual status and the other will instead return with an error.
54.Pp
55For additional information on the thread joining interfaces supported by
56the system, see
57.Xr pthread_join 3C
58and
59.Xr thr_join 3C .
60.Sh RETURN_VALUES
61Upon successful completion, the
62.Fn thrd_join
63function returns
64.Sy thrd_success
65and if
66.Fa res
67is a non-null pointer, it will be filled in with the exit status of
68.Xr thrd .
69If an error occurs,
70.Sy thrd_error
71will be returned.
72.Sh INTERFACE STABILITY
73.Sy Standard
74.Sh MT-LEVEL
75.Sy MT-Safe
76.Sh SEE ALSO
77.Xr pthread_join 3C ,
78.Xr thrd_create 3C ,
79.Xr thrd_detach 3C ,
80.Xr attributes 5 ,
81.Xr threads 5
82