]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
c11b1abf | 2 | .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com> |
2c731798 | 3 | .\" |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
2c731798 | 5 | .\" |
4c1c5274 | 6 | .TH sem_post 3 (date) "Linux man-pages (unreleased)" |
2c731798 MK |
7 | .SH NAME |
8 | sem_post \- unlock a semaphore | |
87b2352b AC |
9 | .SH LIBRARY |
10 | POSIX threads library | |
8fc3b2cf | 11 | .RI ( libpthread ", " \-lpthread ) |
2c731798 MK |
12 | .SH SYNOPSIS |
13 | .nf | |
14 | .B #include <semaphore.h> | |
68e4db0a | 15 | .PP |
2c731798 MK |
16 | .BI "int sem_post(sem_t *" sem ); |
17 | .fi | |
18 | .SH DESCRIPTION | |
19 | .BR sem_post () | |
20 | increments (unlocks) the semaphore pointed to by | |
21 | .IR sem . | |
22 | If the semaphore's value consequently becomes greater than zero, | |
c13182ef | 23 | then another process or thread blocked in a |
2c731798 MK |
24 | .BR sem_wait (3) |
25 | call will be woken up and proceed to lock the semaphore. | |
26 | .SH RETURN VALUE | |
27 | .BR sem_post () | |
c13182ef | 28 | returns 0 on success; |
2c731798 MK |
29 | on error, the value of the semaphore is left unchanged, |
30 | \-1 is returned, and | |
c13182ef | 31 | .I errno |
2c731798 MK |
32 | is set to indicate the error. |
33 | .SH ERRORS | |
34 | .TP | |
35 | .B EINVAL | |
36 | .I sem | |
37 | is not a valid semaphore. | |
642ff1cc MK |
38 | .TP |
39 | .B EOVERFLOW | |
40 | .\" Added in POSIX.1-2008 TC1 (Austin Interpretation 213) | |
41 | The maximum allowable value for a semaphore would be exceeded. | |
c27b616f | 42 | .SH ATTRIBUTES |
8033b62c PH |
43 | For an explanation of the terms used in this section, see |
44 | .BR attributes (7). | |
45 | .TS | |
46 | allbox; | |
c466875e | 47 | lbx lb lb |
8033b62c PH |
48 | l l l. |
49 | Interface Attribute Value | |
50 | T{ | |
9e54434e BR |
51 | .na |
52 | .nh | |
c27b616f | 53 | .BR sem_post () |
8033b62c PH |
54 | T} Thread safety MT-Safe |
55 | .TE | |
c466875e | 56 | .sp 1 |
3113c7f3 | 57 | .SH STANDARDS |
4131356c AC |
58 | POSIX.1-2008. |
59 | .SH HISTORY | |
2c731798 MK |
60 | POSIX.1-2001. |
61 | .SH NOTES | |
62 | .BR sem_post () | |
63 | is async-signal-safe: | |
64 | it may be safely called within a signal handler. | |
a14af333 | 65 | .SH EXAMPLES |
40bc92e5 | 66 | See |
3d5a6df0 MK |
67 | .BR sem_wait (3) |
68 | and | |
69 | .BR shm_open (3). | |
47297adb | 70 | .SH SEE ALSO |
2c731798 MK |
71 | .BR sem_getvalue (3), |
72 | .BR sem_wait (3), | |
46fc35d5 | 73 | .BR sem_overview (7), |
28a4c58c | 74 | .BR signal\-safety (7) |