1sem_post(3)                Library Functions Manual                sem_post(3)
2
3
4

NAME

6       sem_post - unlock a semaphore
7

LIBRARY

9       POSIX threads library (libpthread, -lpthread)
10

SYNOPSIS

12       #include <semaphore.h>
13
14       int sem_post(sem_t *sem);
15

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

STANDARDS

44       POSIX.1-2008.
45

HISTORY

47       POSIX.1-2001.
48

NOTES

50       sem_post()  is  async-signal-safe:  it  may  be  safely called within a
51       signal handler.
52

EXAMPLES

54       See sem_wait(3) and shm_open(3).
55

SEE ALSO

57       sem_getvalue(3), sem_wait(3), sem_overview(7), signal-safety(7)
58
59
60
61Linux man-pages 6.05              2023-07-20                       sem_post(3)
Impressum