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       └────────────────────────────────────────────┴───────────────┴─────────┘
41

CONFORMING TO

43       POSIX.1-2001.
44

NOTES

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

EXAMPLES

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

SEE ALSO

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

COLOPHON

56       This page is part of release 5.13 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                             2021-03-22                       SEM_POST(3)
Impressum