pthread_attr_setdetachstate(3pthread)
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(3pthread),
pthread_attr_setstackaddr(3pthread),
pthread_attr_setstacksize(3pthread),
pthread_create(3pthread),
pthread(4)
Standards compliance
The Single UNIX Specification, Version 2; The Open Group.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004