]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sem_post.3
pthread_attr_init.3: Use correct printf() specifier for "size_t" in example program
[thirdparty/man-pages.git] / man3 / sem_post.3
CommitLineData
2c731798 1'\" t
c11b1abf 2.\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
2c731798 3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
2c731798
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
2c731798
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
2c731798
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
2c731798 25.\"
31a1b45e 26.TH SEM_POST 3 2017-03-13 "Linux" "Linux Programmer's Manual"
2c731798
MK
27.SH NAME
28sem_post \- unlock a semaphore
29.SH SYNOPSIS
30.nf
31.B #include <semaphore.h>
68e4db0a 32.PP
2c731798
MK
33.BI "int sem_post(sem_t *" sem );
34.fi
68e4db0a 35.PP
2c5f8c8c 36Link with \fI\-pthread\fP.
2c731798
MK
37.SH DESCRIPTION
38.BR sem_post ()
39increments (unlocks) the semaphore pointed to by
40.IR sem .
41If the semaphore's value consequently becomes greater than zero,
c13182ef 42then another process or thread blocked in a
2c731798
MK
43.BR sem_wait (3)
44call will be woken up and proceed to lock the semaphore.
45.SH RETURN VALUE
46.BR sem_post ()
c13182ef 47returns 0 on success;
2c731798
MK
48on error, the value of the semaphore is left unchanged,
49\-1 is returned, and
c13182ef 50.I errno
2c731798
MK
51is set to indicate the error.
52.SH ERRORS
53.TP
54.B EINVAL
55.I sem
56is not a valid semaphore.
642ff1cc
MK
57.TP
58.B EOVERFLOW
59.\" Added in POSIX.1-2008 TC1 (Austin Interpretation 213)
60The maximum allowable value for a semaphore would be exceeded.
c27b616f 61.SH ATTRIBUTES
8033b62c
PH
62For an explanation of the terms used in this section, see
63.BR attributes (7).
64.TS
65allbox;
66lb lb lb
67l l l.
68Interface Attribute Value
69T{
c27b616f 70.BR sem_post ()
8033b62c
PH
71T} Thread safety MT-Safe
72.TE
2c731798
MK
73.SH CONFORMING TO
74POSIX.1-2001.
75.SH NOTES
76.BR sem_post ()
77is async-signal-safe:
78it may be safely called within a signal handler.
40bc92e5
MK
79.SH EXAMPLE
80See
81.BR sem_wait (3).
47297adb 82.SH SEE ALSO
2c731798
MK
83.BR sem_getvalue (3),
84.BR sem_wait (3),
46fc35d5
MK
85.BR sem_overview (7),
86.BR signal-safety (7)