DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pthread_attr_setdetachstate(PTHREAD)


pthread_attr_setdetachstate, pthread_attr_getdetachstate -- set and get detachstate attribute

Synopsis

cc [options] -Kthread file

#include <pthread.h>

int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);

Description

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 pthread_detach or pthread_join is an error.

pthread_attr_setdetachstate and pthread_attr_getdetachstate respectively, set and get the detachstate attribute in the attr object.

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 .

Return values

Upon successful completion, pthread_attr_setdetachstate and pthread_attr_getdetachstate return a value of 0. Otherwise, an error number is returned to indicate the error.

pthread_attr_getdetachstate stores the value of the detachstate attribute in detachstate if successful.

Diagnostics

If the following condition is detected, pthread_attr_setdetachstate returns the corresponding value:

EINVAL
invalid detachstate specified
If the following condition is detected, pthread_attr_setdetachstate and pthread_attr_getdetachstate return the corresponding value:

EINVAL
invalid attr specified

References

pthread_attr_init(PTHREAD), pthread_attr_setstackaddr(PTHREAD), pthread_attr_setstacksize(PTHREAD), pthread_create(PTHREAD), pthread(F)

Standards compliance

The Single UNIX Specification, Version 2; The Open Group.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005