pthread_condattr_destroy() — Destroy condition variable attribute object

Standards

Standards / Extensions C or C++ Dependencies
POSIX.4a
Single UNIX Specification, Version 3
both
POSIX(ON)

Format

#define _OPEN_THREADS
#include <pthread.h>

int pthread_condattr_destroy(pthread_condattr_t *attr);
SUSV3:
#define _UNIX03_THREADS
#include <pthread.h>

int pthread_condattr_destroy(pthread_condattr_t *attr);

General description

Destroys a condition attribute object. Condition-variable attribute objects are similar to mutex attribute objects because you can use them to manage the characteristics of condition variables in your application. They define the set of values to be used for the condition variable during its creation.

pthread_condattr_init() is used to define a condition variable attribute object. pthread_condattr_destroy() is used to remove the definition of the condition variable attribute object. These functions are provided for portability purposes.

You can define a condition variable without using these functions by supplying a NULL parameter during the pthread_cond_init() call. For more details, refer to pthread_cond_init() — Initialize a condition variable.

Returned value

If successful, pthread_condattr_destroy() returns 0.

If unsuccessful, pthread_condattr_destroy() returns -1 and sets errno to one of the following values:
Error Code
Description
EINVAL
The value specified by attr is not valid.

Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_condattr_destroy() returns an error number to indicate the error.

Example

CELEBP23
/* CELEBP23 */                                   
#define _OPEN_THREADS                                                           
#include <pthread.h>                                                            
#include <stdio.h>                                                              
                                                                                
main() {                                                                        
  pthread_condattr_t cond;                                                      
                                                                                
  if (pthread_condattr_init(&cond) != 0) {                                      
    perror("pthread_condattr_init() error");                                    
    exit(1);                                                                    
  }                                                                             
                                                                                
  if (pthread_condattr_destroy(&cond) != 0) {                                   
    perror("pthread_condattr_destroy() error");                                 
    exit(2);                                                                    
  }                                                                             
}                                                                               

Related information