Multithreaded Programming Guide

Destroy a Mutex


Use pthread_mutex_destroy(3T) to destroy any state associated with the mutex pointed to by mp. (For Solaris threads, see "mutex_destroy(3T)".)

int	pthread_mutex_destroy(pthread_mutex_t *mp); 
#include <pthread.h>

pthread_mutex_t mp;
int ret;

ret = pthread_mutex_destroy(&mp); /* mutex is destroyed */

Note that the space for storing the mutex is not freed.

Return Values

pthread_mutex_destroy() returns zero after completing successfully. Any other returned value indicates that an error occurred. When any of the following conditions occur, the function fails and returns the corresponding value.


The value specified by mp does not refer to an initialized mutex object.