Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.4a |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
int pthread_mutex_destroy(pthread_mutex_t *mutex);
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_mutex_destroy(pthread_mutex_t *mutex);
Deletes a mutex object, which identifies a mutex. Mutexes are used to protect shared resources. mutex is set to an invalid value, but can be reinitialized using pthread_mutex_init().
If successful, pthread_mutex_destroy() returns 0.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_mutex_destroy() returns an error number to indicate the error.
⁄* CELEBP36 *⁄
#define _OPEN_THREADS
#include <pthread.h>
#include <stdio.h>
main() {
pthread_mutex_t mutex;
if (pthread_mutex_init(&mutex, NULL) != 0) {
perror("pthread_mutex_init() error");
exit(1);
}
if (pthread_mutex_destroy(&mutex) != 0) {
perror("pthread_mutex_destroy() error");
exit(2);
}
}