Debian Codegraph @

upstream/debian-trixie/man3/sem_post.3

raw
1 '\" t
2 .\" Copyright (C) 2006 Michael Kerrisk <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH sem_post 3 2024-05-02 "Linux man-pages 6.9.1"
7 .SH NAME
8 sem_post \- unlock a semaphore
9 .SH LIBRARY
10 POSIX threads library
11 .RI ( libpthread ", " \-lpthread )
12 .SH SYNOPSIS
13 .nf
14 .B #include <semaphore.h>
15 .P
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,
23 then another process or thread blocked in a
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 ()
28 returns 0 on success;
29 on error, the value of the semaphore is left unchanged,
30 \-1 is returned, and
31 .I errno
32 is set to indicate the error.
33 .SH ERRORS
34 .TP
35 .B EINVAL
36 .I sem
37 is not a valid semaphore.
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.
42 .SH ATTRIBUTES
43 For an explanation of the terms used in this section, see
44 .BR attributes (7).
45 .TS
46 allbox;
47 lbx lb lb
48 l l l.
49 Interface Attribute Value
50 T{
51 .na
52 .nh
53 .BR sem_post ()
54 T} Thread safety MT-Safe
55 .TE
56 .SH STANDARDS
57 POSIX.1-2008.
58 .SH HISTORY
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.
64 .SH EXAMPLES
65 See
66 .BR sem_wait (3)
67 and
68 .BR shm_open (3).
69 .SH SEE ALSO
70 .BR sem_getvalue (3),
71 .BR sem_wait (3),
72 .BR sem_overview (7),
73 .BR signal\-safety (7)