1SEM_POST(3) Linux Programmer's Manual SEM_POST(3)
2
3
4
6 sem_post - unlock a semaphore
7
9 #include <semaphore.h>
10
11 int sem_post(sem_t *sem);
12
13 Link with -pthread.
14
16 sem_post() increments (unlocks) the semaphore pointed to by sem. If
17 the semaphore's value consequently becomes greater than zero, then
18 another process or thread blocked in a sem_wait(3) call will be woken
19 up and proceed to lock the semaphore.
20
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
24 error.
25
27 EINVAL sem is not a valid semaphore.
28
29 EOVERFLOW
30 The maximum allowable value for a semaphore would be exceeded.
31
33 For an explanation of the terms used in this section, see
34 attributes(7).
35
36 ┌───────────┬───────────────┬─────────┐
37 │Interface │ Attribute │ Value │
38 ├───────────┼───────────────┼─────────┤
39 │sem_post() │ Thread safety │ MT-Safe │
40 └───────────┴───────────────┴─────────┘
42 POSIX.1-2001.
43
45 sem_post() is async-signal-safe: it may be safely called within a sig‐
46 nal handler.
47
49 See sem_wait(3).
50
52 sem_getvalue(3), sem_wait(3), sem_overview(7), signal-safety(7)
53
55 This page is part of release 5.02 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 2017-03-13 SEM_POST(3)