Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pthread_attr_getdetachstate(3) [netbsd man page]

PTHREAD_ATTR_GETDETACHSTATE(3)				   BSD Library Functions Manual 			    PTHREAD_ATTR_GETDETACHSTATE(3)

NAME
pthread_attr_getdetachstate -- get and set the ``detach state'' attribute LIBRARY
POSIX Threads Library (libpthread, -lpthread) SYNOPSIS
#include <pthread.h> int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); DESCRIPTION
The attribute parameters for the pthread_attr_getdetachstate() and pthread_attr_setdetachstate() functions are mutually exclusive and must be one of: PTHREAD_CREATE_JOINABLE The threads must explicitly be waited for using the pthread_join(3) function once they exit for their status to be received and their resources to be freed. This is the default. PTHREAD_CREATE_DETACHED The thread's resources will automatically be freed once the thread exits, and the thread will not be joined. If the thread is created as detached, it is an error to use the thread ID with pthread_detach(3) or pthread_join(3). RETURN VALUES
If successful, these functions return 0. Otherwise, an error number is returned to indicate the error. ERRORS
No errors are defined for pthread_attr_getdetachstate(). The pthread_attr_setdetachstate() function should fail if: [EINVAL] The value specified by detachstate is invalid. SEE ALSO
pthread_attr(3), pthread_detach(3), pthread_join(3) STANDARDS
Both functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). BSD
July 9, 2010 BSD

Check Out this Related Man Page

pthread_attr_getdetachstate(3C) 										   pthread_attr_getdetachstate(3C)

NAME
pthread_attr_getdetachstate, pthread_attr_setdetachstate - get or set detachstate attribute SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ] #include <pthread.h> int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); The detachstate attribute controls whether the thread is created in a detached state. If the thread is created detached, then use of the ID of the newly created thread by the pthread_detach() or pthread_join() function is an error. The pthread_attr_setdetachstate() and pthread_attr_getdetachstate(), respectively, set and get the detachstate attribute in the attr object. The detachstate can be set to either PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE. A value of PTHREAD_CREATE_DETACHED causes all threads created with attr to be in the detached state, whereas using a value of PTHREAD_CREATE_JOINABLE causes all threads created with attr to be in the joinable state. The default value of the detachstate attribute is PTHREAD_CREATE_JOINABLE. Upon successful completion, pthread_attr_setdetachstate() and pthread_attr_getdetachstate() return a value of 0. Otherwise, an error num- ber is returned to indicate the error. The pthread_attr_getdetachstate() function stores the value of the detachstate attribute in detachstate if successful. The pthread_attr_setdetachstate() or pthread_attr_getdetachstate() functions may fail if: EINVAL attr or detachstate is invalid. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ pthread_attr_init(3C), pthread_attr_setstackaddr(3C), pthread_attr_setstacksize(3C), pthread_create(3C), attributes(5), standards(5) 23 Mar 2005 pthread_attr_getdetachstate(3C)
Man Page