DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

sem_destroy(3pthread)


sem_destroy -- destroy an unnamed semaphore

Synopsis

   cc [options] -Kthread file
   

#include <semaphore.h>

int sem_destroy(sem_t *sem);

Description

sem_destroy destroys the semaphore pointed to by sem. This includes invalidating sem and freeing any associated dynamically allocated resources.

Only a semaphore that was previously initialized by sem_init may be destroyed using sem_destroy;

It is safe to destroy an initialized semaphore upon which no threads are currently blocked. The effect of destroying a semaphore upon which other threads are currently blocked is undefined.

Return values

sem_destroy returns zero on success. Otherwise, a value of -1 is returned and errno is set to indicate the error.

Errors

sem_destroy returns the following value if the corresponding condition is detected:

EINVAL
The sem argument is not a valid semaphore.

EBUSY
There are currently threads blocked on the semaphore.

Standards compliance

The Single UNIX Specification, Version 2; The Open Group.

References

Intro(3pthread), sem_init(3pthread), sem_open(3pthread), sem_post(3pthread), sem_trywait(3pthread), sem_wait(3pthread), semaphore(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004