1.\" $OpenBSD: pthread_attr_setdetachstate.3,v 1.10 2013/06/05 03:44:50 tedu Exp $ 2.\" Manual page derived from TOG's UNIX98 documentation. 3.\" 4.\" David Leonard, 2000. Public Domain. 5.\" 6.Dd $Mdocdate: June 5 2013 $ 7.Dt PTHREAD_ATTR_SETDETACHSTATE 3 8.Os 9.Sh NAME 10.Nm pthread_attr_setdetachstate , 11.Nm pthread_attr_getdetachstate 12.Nd set and get detachstate attribute 13.Sh SYNOPSIS 14.In pthread.h 15.Ft int 16.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" 17.Ft int 18.Fn pthread_attr_getdetachstate "pthread_attr_t *attr" "int *detachstate" 19.Sh DESCRIPTION 20The 21.Va detachstate 22attribute controls whether the thread is created in 23a detached state. 24If the thread is created detached, then use of 25the ID of the newly created thread by the 26.Xr pthread_detach 3 27or 28.Xr pthread_join 3 29function is an error. 30.Pp 31The 32.Fn pthread_attr_setdetachstate 33and 34.Fn pthread_attr_getdetachstate 35functions, respectively, set and get the 36.Va detachstate 37attribute in the 38.Fa attr 39object. 40.Pp 41The 42.Fa detachstate 43can be set to either 44.Dv PTHREAD_CREATE_DETACHED 45or 46.Dv PTHREAD_CREATE_JOINABLE . 47A value of 48.Dv PTHREAD_CREATE_DETACHED 49causes 50all threads created with 51.Fa attr 52to be in the detached state, whereas 53using a value of 54.Dv PTHREAD_CREATE_JOINABLE 55causes all threads created 56with 57.Fa attr 58to be in the joinable state. 59The default value of the 60.Va detachstate 61attribute is 62.Dv PTHREAD_CREATE_JOINABLE . 63.Sh RETURN VALUES 64Upon successful completion, 65.Fn pthread_attr_setdetachstate 66and 67.Fn pthread_attr_getdetachstate 68return a value of 0. 69Otherwise, an error number is returned to indicate the error. 70.Pp 71The 72.Fn pthread_attr_getdetachstate 73function stores the value of the 74.Va detachstate 75attribute in 76.Fa detachstate 77if successful. 78.Sh ERRORS 79The 80.Fn pthread_attr_setdetachstate 81function will fail if: 82.Bl -tag -width Er 83.It Bq Er EINVAL 84The value of 85.Fa detachstate 86was not valid. 87.El 88.Pp 89These functions will not return an error code of 90.Bq Er EINTR . 91.Sh SEE ALSO 92.Xr pthread_attr_init 3 , 93.Xr pthread_attr_setguardsize 3 , 94.Xr pthread_attr_setstack 3 , 95.Xr pthread_attr_setstackaddr 3 , 96.Xr pthread_attr_setstacksize 3 , 97.Xr pthread_create 3 , 98.Xr pthreads 3 99.Sh STANDARDS 100.Fn pthread_attr_setdetachstate 101and 102.Fn pthread_attr_getdetachstate 103conform to ISO/IEC 9945-1 ANSI/IEEE 104.Pq Dq Tn POSIX 105Std 1003.1 Second Edition 1996-07-12. 106