pthread_attr_setdetachstate

Sets the detached state of a thread attribute object.

Library:LibC
Classification:POSIX
Service:Threads

Syntax

  #include <pthread.h>
   
  int   pthread_attr_setdetachstate (
     pthread_attr_t   *attr,
     int               detachstate);
  

Parameters

attr

(IN) Points to the attribute structure.

detachstate

(IN) Specifies the detached state with one of the following flags:

  • PTHREAD_CREATE_JOINABLE (0)
  • PTHREAD_CREATE_DETACHED (0x00000010)

Return Values

If successful, returns zero; otherwise returns a nonzero error code:

Decimal

Constant

Description

9

EINVAL

The detachstate parameter is invalid.

Remarks

The pthread_attr_init function initializes the detached state attribute to PTHREAD_CREATE_JOINABLE.

After the thread is created, a joinable thread can be changed to a detached thread, but a detached thread cannot be modified to become a joinable thread.

See Also