[Previous]
[Contents]
[Next]

sem_destroy()

destroy a semaphore

Synopsis:

#include <semaphore.h>
int sem_destroy( sem_t *sem );

Description:

The sem_destroy() function destroys the unnamed semaphore referred to by the sem argument. The semaphore must have been previously initialized by the sem_init() function.

The effect of using a semaphore after it has been destroyed is undefined. Also, if you destroy a semaphore on which other processes are currently blocked, they're unblocked, with an error (EINVAL).

Returns:

0
Success.
-1
An error occurred. errno is set to indicate the error.

Errors:

EINVAL
The sem argument isn't a valid semaphore.
ENOSYS
The function sem_destroy() isn't supported.

Examples:

/usr/demo/src/semaphores

Classification:

POSIX 1003.1b-1993

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, sem_init(), sem_post(), sem_trywait(), sem_wait()


[Previous]
[Contents]
[Next]