1SEM_DESTROY(3)             Linux Programmer's Manual            SEM_DESTROY(3)
2
3
4

NAME

6       sem_destroy - destroy an unnamed semaphore
7

SYNOPSIS

9       #include <semaphore.h>
10
11       int sem_destroy(sem_t *sem);
12

DESCRIPTION

14       sem_destroy()  destroys the unnamed semaphore at the address pointed to
15       by sem.
16
17       Only a semaphore that has been initialised  by  sem_init(3)  should  be
18       destroyed using sem_destroy().
19
20       Destroying  a  semaphore  that other processes or threads are currently
21       blocked on (in sem_wait(3)) produces undefined behaviour.
22
23       Using a semaphore that has been destroyed produces  undefined  results,
24       until the semaphore has been reinitialised using sem_init(3).
25

RETURN VALUE

27       sem_destroy() returns 0 on success; on error, -1 is returned, and errno
28       is set to indicate the error.
29

ERRORS

31       EINVAL sem is not a valid semaphore.
32

CONFORMING TO

34       POSIX.1-2001.
35

NOTES

37       An unnamed semaphore should be destroyed with sem_destroy() before  the
38       memory  in  which it is located is deallocated.  Failure to do this can
39       result in resource leaks on some implementations.
40

SEE ALSO

42       sem_init(3), sem_post(3), sem_wait(3), sem_overview(7)
43
44
45
46Linux 2.6.16                      2006-03-25                    SEM_DESTROY(3)
Impressum