]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sem_getvalue.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / sem_getvalue.3
CommitLineData
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_GETVALUE 3 2021-03-22 "Linux man-pages (unreleased)"
2c731798
MK
6.SH NAME
7sem_getvalue \- get the value of a semaphore
911c89d5
AC
8.SH LIBRARY
9POSIX threads library
8fc3b2cf 10.RI ( libpthread ", " \-lpthread )
2c731798
MK
11.SH SYNOPSIS
12.nf
13.B #include <semaphore.h>
68e4db0a 14.PP
439cb1d4 15.BI "int sem_getvalue(sem_t *restrict " sem ", int *restrict " sval );
2c731798
MK
16.fi
17.SH DESCRIPTION
18.BR sem_getvalue ()
19places the current value of the semaphore pointed to
20.I sem
21into the integer pointed to by
22.IR sval .
847e0d88 23.PP
c13182ef 24If one or more processes or threads are blocked
2c731798
MK
25waiting to lock the semaphore with
26.BR sem_wait (3),
4b6fa602 27POSIX.1 permits two possibilities for the value returned in
4509e795 28.IR sval :
c13182ef
MK
29either 0 is returned;
30or a negative number whose absolute value is the count
2c731798
MK
31of the number of processes and threads currently blocked in
32.BR sem_wait (3).
d9bfdb9c 33Linux adopts the former behavior.
2c731798
MK
34.SH RETURN VALUE
35.BR sem_getvalue ()
c13182ef 36returns 0 on success;
2c731798 37on error, \-1 is returned and
c13182ef 38.I errno
2c731798
MK
39is set to indicate the error.
40.SH ERRORS
41.TP
42.B EINVAL
43.I sem
44is not a valid semaphore.
777ab17e
MK
45(The glibc implementation currently does not check whether
46.I sem
47is valid.)
044738b4 48.SH ATTRIBUTES
3533c7f0
PH
49For an explanation of the terms used in this section, see
50.BR attributes (7).
c466875e
MK
51.ad l
52.nh
3533c7f0
PH
53.TS
54allbox;
c466875e 55lbx lb lb
3533c7f0
PH
56l l l.
57Interface Attribute Value
58T{
044738b4 59.BR sem_getvalue ()
3533c7f0
PH
60T} Thread safety MT-Safe
61.TE
c466875e
MK
62.hy
63.ad
64.sp 1
3113c7f3 65.SH STANDARDS
4b6fa602 66POSIX.1-2001, POSIX.1-2008.
2c731798
MK
67.SH NOTES
68The value of the semaphore may already have changed by the time
69.BR sem_getvalue ()
70returns.
47297adb 71.SH SEE ALSO
2c731798
MK
72.BR sem_post (3),
73.BR sem_wait (3),
74.BR sem_overview (7)