pthread_attr_setdetachstate Subroutine Purpose Sets the value of the detachstate attribute of a thread attributes object. Library Threads Library (libpthreads.a) Syntax #include
int pthread_attr_setdetachstate (attr, detachstate) pthread_attr_t *attr; int detachstate; Description The pthread_attr_setdetachstate subroutine sets the value of the detachstate attribute of the thread attributes object attr. This attribute specifies the detached state of a thread created with this attributes object. Note: The pthread.h header file must be the first included file of each source file using the threads library. Parameters attr Specifies the thread attributes object. detachstate Specifies the detached state to set. It must have one of the following values: PTHREAD_CREATE_DETACHED Specifies that the thread will be created in detached state. This is the default value. PTHREAD_CREATE_UNDETACHED Specifies that the thread will be created in undetached state. Return Values Upon successful completion, 0 is returned. Otherwise, an error code is returned. Error Codes The pthread_attr_setdetachstate subroutine is unsuccessful if the following is true: EINVAL The attr or detachstate parameters are not valid. Implementation Specifics This subroutine is part of the Base Operating System (BOS) Runtime. Related Information The pthread_attr_getdetachstate subroutine, pthread_attr_init subroutine, pthread_create subroutine. Creating Threads. Threads Library Quick Reference.