Debian Codegraph @

upstream/debian-unstable/man3/sem_post.3

raw
1 '\" t
2 .\" Copyright 2006, Michael Kerrisk <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH sem_post 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 sem_post \- unlock a semaphore
10 .SH LIBRARY
11 POSIX threads library
12 .RI ( libpthread ,\~ \-lpthread )
13 .SH SYNOPSIS
14 .nf
15 .B #include <semaphore.h>
16 .P
17 .BI "int sem_post(sem_t *" sem );
18 .fi
19 .SH DESCRIPTION
20 .BR sem_post ()
21 increments (unlocks) the semaphore pointed to by
22 .IR sem .
23 If the semaphore's value consequently becomes greater than zero,
24 then another process or thread blocked in a
25 .BR sem_wait (3)
26 call will be woken up and proceed to lock the semaphore.
27 .SH RETURN VALUE
28 .BR sem_post ()
29 returns 0 on success;
30 on error, the value of the semaphore is left unchanged,
31 \-1 is returned, and
32 .I errno
33 is set to indicate the error.
34 .SH ERRORS
35 .TP
36 .B EINVAL
37 .I sem
38 is not a valid semaphore.
39 .TP
40 .B EOVERFLOW
41 .\" Added in POSIX.1-2008 TC1 (Austin Interpretation 213)
42 The value would exceed
43 .BR SEM_VALUE_MAX .
44 .SH ATTRIBUTES
45 For an explanation of the terms used in this section, see
46 .BR attributes (7).
47 .TS
48 allbox;
49 lbx lb lb
50 l l l.
51 Interface Attribute Value
52 T{
53 .na
54 .nh
55 .BR sem_post ()
56 T} Thread safety MT-Safe
57 .TE
58 .SH STANDARDS
59 POSIX.1-2008.
60 .SH HISTORY
61 POSIX.1-2001.
62 .SH NOTES
63 .BR sem_post ()
64 is async-signal-safe:
65 it may be safely called within a signal handler.
66 .SH EXAMPLES
67 See
68 .BR sem_wait (3)
69 and
70 .BR shm_open (3).
71 .SH SEE ALSO
72 .BR sem_getvalue (3),
73 .BR sem_wait (3),
74 .BR sem_overview (7),
75 .BR signal\-safety (7)