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

ATTRIBUTES

36       For  an  explanation  of  the  terms  used   in   this   section,   see
37       attributes(7).
38
39       ┌──────────────┬───────────────┬─────────┐
40Interface     Attribute     Value   
41       ├──────────────┼───────────────┼─────────┤
42sem_destroy() │ Thread safety │ MT-Safe │
43       └──────────────┴───────────────┴─────────┘

CONFORMING TO

45       POSIX.1-2001, POSIX.1-2008.
46

NOTES

48       An  unnamed semaphore should be destroyed with sem_destroy() before the
49       memory in which it is located is deallocated.  Failure to do  this  can
50       result in resource leaks on some implementations.
51

SEE ALSO

53       sem_init(3), sem_post(3), sem_wait(3), sem_overview(7)
54

COLOPHON

56       This  page  is  part of release 5.04 of the Linux man-pages project.  A
57       description of the project, information about reporting bugs,  and  the
58       latest     version     of     this    page,    can    be    found    at
59       https://www.kernel.org/doc/man-pages/.
60
61
62
63Linux                             2017-09-15                    SEM_DESTROY(3)
Impressum