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

NAME

6       sem_post - unlock a semaphore
7

SYNOPSIS

9       #include <semaphore.h>
10
11       int sem_post(sem_t *sem);
12
13       Link with -pthread.
14

DESCRIPTION

16       sem_post()  increments  (unlocks)  the semaphore pointed to by sem.  If
17       the semaphore's value consequently becomes greater than zero, then  an‐
18       other  process or thread blocked in a sem_wait(3) call will be woken up
19       and proceed to lock the semaphore.
20

RETURN VALUE

22       sem_post() returns 0 on success; on error, the value of  the  semaphore
23       is left unchanged, -1 is returned, and errno is set to indicate the er‐
24       ror.
25

ERRORS

27       EINVAL sem is not a valid semaphore.
28
29       EOVERFLOW
30              The maximum allowable value for a semaphore would be exceeded.
31

ATTRIBUTES

33       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
34       tributes(7).
35
36       ┌───────────┬───────────────┬─────────┐
37Interface  Attribute     Value   
38       ├───────────┼───────────────┼─────────┤
39sem_post() │ Thread safety │ MT-Safe │
40       └───────────┴───────────────┴─────────┘

CONFORMING TO

42       POSIX.1-2001.
43

NOTES

45       sem_post()  is async-signal-safe: it may be safely called within a sig‐
46       nal handler.
47

EXAMPLES

49       See sem_wait(3) and shm_open(3).
50

SEE ALSO

52       sem_getvalue(3), sem_wait(3), sem_overview(7), signal-safety(7)
53

COLOPHON

55       This page is part of release 5.10 of the Linux  man-pages  project.   A
56       description  of  the project, information about reporting bugs, and the
57       latest    version    of    this    page,    can     be     found     at
58       https://www.kernel.org/doc/man-pages/.
59
60
61
62Linux                             2020-08-13                       SEM_POST(3)
Impressum