]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sem_getvalue.3
dlinfo.3: tfix
[thirdparty/man-pages.git] / man3 / sem_getvalue.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.\"
4b8c67d9 26.TH SEM_GETVALUE 3 2017-09-15 "Linux" "Linux Programmer's Manual"
2c731798
MK
27.SH NAME
28sem_getvalue \- get the value of a semaphore
29.SH SYNOPSIS
30.nf
31.B #include <semaphore.h>
68e4db0a 32.PP
2c731798
MK
33.BI "int sem_getvalue(sem_t *" sem ", int *" sval );
34.fi
68e4db0a 35.PP
2c5f8c8c 36Link with \fI\-pthread\fP.
2c731798
MK
37.SH DESCRIPTION
38.BR sem_getvalue ()
39places the current value of the semaphore pointed to
40.I sem
41into the integer pointed to by
42.IR sval .
847e0d88 43.PP
c13182ef 44If one or more processes or threads are blocked
2c731798
MK
45waiting to lock the semaphore with
46.BR sem_wait (3),
4b6fa602 47POSIX.1 permits two possibilities for the value returned in
4509e795 48.IR sval :
c13182ef
MK
49either 0 is returned;
50or a negative number whose absolute value is the count
2c731798
MK
51of the number of processes and threads currently blocked in
52.BR sem_wait (3).
d9bfdb9c 53Linux adopts the former behavior.
2c731798
MK
54.SH RETURN VALUE
55.BR sem_getvalue ()
c13182ef 56returns 0 on success;
2c731798 57on error, \-1 is returned and
c13182ef 58.I errno
2c731798
MK
59is set to indicate the error.
60.SH ERRORS
61.TP
62.B EINVAL
63.I sem
64is not a valid semaphore.
044738b4 65.SH ATTRIBUTES
3533c7f0
PH
66For an explanation of the terms used in this section, see
67.BR attributes (7).
68.TS
69allbox;
70lb lb lb
71l l l.
72Interface Attribute Value
73T{
044738b4 74.BR sem_getvalue ()
3533c7f0
PH
75T} Thread safety MT-Safe
76.TE
2b2581ee 77.SH CONFORMING TO
4b6fa602 78POSIX.1-2001, POSIX.1-2008.
2c731798
MK
79.SH NOTES
80The value of the semaphore may already have changed by the time
81.BR sem_getvalue ()
82returns.
47297adb 83.SH SEE ALSO
2c731798
MK
84.BR sem_post (3),
85.BR sem_wait (3),
86.BR sem_overview (7)