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