sem_destroy()

destroy an unnamed semaphore 

Realtime Function


SYNOPSIS

#include <semaphore.h>

int sem_destroy(sem_t *sem);


DESCRIPTION

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 sem_init() function. 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 undefined effects.

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 malloc()ed. You should only use sem_destroy() with semaphores created by sem_init() and only use sem_close() with semaphores created with sem_open().


PARAMETERS

sem 

Specifies the unnamed semaphore to be destroyed.


RETURN VALUES

When successful, sem_destroy() returns zero. Otherwise, it returns -1 is returned and sets errno to one of the following values:

EINVAL 

The sem argument is not a valid semaphore.

EBUSY 

There are currently processes blocked on the semaphore.


EXAMPLES

None.


CONFORMANCE

UNIX 03. Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

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


SEE ALSO

Functions:
sem_init(), sem_open(), semctl(), semget(), semop()

Miscellaneous:
semaphores


PTC MKS Toolkit 10.4 Documentation Build 39.