pthread_attr_setdetachstate()

set detached state attribute 

Function


SYNOPSIS

#include <pthread.h>

int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);


DESCRIPTION

The pthread_attr_setdetachstate() function sets the detached state attribute in the specified attribute object. The thread's detached state determines whether another thread may wait for the termination of the thread. Valid settings for detachstate include:

PTHREAD_CREATE_DETACHED 

Creates a new detached thread. A detached thread disappears without leaving a trace. The thread ID and any of its resources are freed and ready for reuse. pthread_join() cannot wait for a detached thread.

PTHREAD_CREATE_JOINABLE 

Creates a new non-detached thread. The thread ID and some of the threads other resources are not freed until pthread_join() is called. pthread_join() must be called to release any resources associated with the terminated thread.


PARAMETERS

attr 

Is a thread attribute object.

detachstate  

Is the thread detached state attribute value; one of the values specified in the DESCRIPTION section.


RETURN VALUES

On success, pthread_attr_setdetachstate() returns 0. On error, one of the following values is returned:

EINVAL 

attr is not an initialized thread attribute object, or detachstate is not a valid detached state setting.

EFAULT 

attr is not a valid pointer.


CONFORMANCE

POSIX P1003.1 (1996)


MULTITHREAD SAFETY LEVEL

MT-safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
pthread_attr_getdetachstate(), pthread_attr_init(), pthread_create(), pthread_join()


PTC MKS Toolkit 10.3 Documentation Build 39.