int sem_destroy(sem_t *sem);
The sem_destroy() function destroys the unnamed semaphore
specified by the sem argument.
You can only use this function to destroy a semaphore created with the
Additionally, subsequent use of the specified semaphore by another semaphore
function results in that function failing with errno set to
EINVAL. Reinitializing the semaphore with the
sem_init() function allows it to be used again.
Only semaphores on which no threads are currently blocked can be safely
destroyed. Attempting to destroy a semaphore with currently blocked threads has
Attempting to destroy a named semaphore (that is, a semaphore created
by the sem_open() function) with this function
can result in heap corruption or freeing resources that were not
You should only use sem_destroy()
with semaphores created by sem_init() and only use
sem_close() with semaphores created with
Specifies the unnamed semaphore to be destroyed.
When successful, sem_destroy() returns zero.
Otherwise, it returns -1 is returned and sets errno to one
of the following values:
The sem argument is not a valid semaphore.
There are currently processes blocked on the semaphore.
Derived from the POSIX Realtime Extension
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
- sem_init(), sem_open(), semctl(), semget(), semop()
PTC MKS Toolkit 10.3 Documentation Build 39.