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
13       Link with -pthread.
14

DESCRIPTION

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

RETURN VALUE

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

ERRORS

33       EINVAL sem is not a valid semaphore.
34

CONFORMING TO

36       POSIX.1-2001.
37

NOTES

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

SEE ALSO

44       sem_init(3), sem_post(3), sem_wait(3), sem_overview(7)
45

COLOPHON

47       This page is part of release 3.53 of the Linux  man-pages  project.   A
48       description  of  the project, and information about reporting bugs, can
49       be found at http://www.kernel.org/doc/man-pages/.
50
51
52
53Linux                             2012-05-13                    SEM_DESTROY(3)
Impressum