Email List: Xaustin-review-lX
[All Lists]

Defect in XSH pthread_attr_getdetachstate

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Defect in XSH pthread_attr_getdetachstate
From: yyyyyyyy@xxxxxxx
Date: Mon, 21 Jul 2003 14:55:17 +0100 (BST)
        Defect report from : Loic Domaigne , personal interest

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 0 line 0 section pthread_attr_getdetachstate comment 
{pthread_attr_getdetachstate}

Problem:

Edition of Specification (Year): 2003

Defect code :  2. Omission

Missing example.

Action:

The following function prints on stdio the detachstate of the thread 
attribute referenced by ptr_attr. This function illustrates the use 
of pthread_attr_getdetachstate(). 


#include <pthread.h>
#include <stdio.h>

void 
print_detachstate(const pthread_attr_t* ptr_attr
                  )
{
  int  rc;            /* returned code */
  int  detachstate;   /* detach state  */

  printf("\nDetach state (ptr_attr=%p): ", ptr_attr);

  rc = pthread_attr_getdetachstate (ptr_attr, &detachstate);
  if (rc != 0)  /* handle error */ 
  {             
    printf ("failed to get detachstate <error %d>\n", rc);
  }
  else          /* print detach state */
  {                 
    switch (detachstate)
    {
    case PTHREAD_CREATE_JOINABLE:  /* joignable */
      printf ("joignable\n");
      break;

    case PTHREAD_CREATE_DETACHED:  /* detached  */
      printf ("detached\n");
      break;

    default:                       /* not conform */
      printf ("??? Invalid thread attribute?\n");
      break; 
    } /*  switch (detachstate) */
  }
}

<Prev in Thread] Current Thread [Next in Thread>