1sem_post(3) Library Functions Manual sem_post(3)
2
3
4
6 sem_post - unlock a semaphore
7
9 POSIX threads library (libpthread, -lpthread)
10
12 #include <semaphore.h>
13
14 int sem_post(sem_t *sem);
15
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
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
28 EINVAL sem is not a valid semaphore.
29
30 EOVERFLOW
31 The maximum allowable value for a semaphore would be exceeded.
32
34 For an explanation of the terms used in this section, see at‐
35 tributes(7).
36
37 ┌────────────────────────────────────────────┬───────────────┬─────────┐
38 │Interface │ Attribute │ Value │
39 ├────────────────────────────────────────────┼───────────────┼─────────┤
40 │sem_post() │ Thread safety │ MT-Safe │
41 └────────────────────────────────────────────┴───────────────┴─────────┘
42
44 POSIX.1-2008.
45
47 POSIX.1-2001.
48
50 sem_post() is async-signal-safe: it may be safely called within a
51 signal handler.
52
54 See sem_wait(3) and shm_open(3).
55
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)