mount_setattr.2: Reword the description of the 'propagation field'
[man-pages.git] / man3 / sem_getvalue.3
blob22ce42502c3a57c9de278605146eb6aab57e150e
1 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH SEM_GETVALUE 3 2021-03-22 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 sem_getvalue \- get the value of a semaphore
28 .SH SYNOPSIS
29 .nf
30 .B #include <semaphore.h>
31 .PP
32 .BI "int sem_getvalue(sem_t *restrict " sem ", int *restrict " sval );
33 .fi
34 .PP
35 Link with \fI\-pthread\fP.
36 .SH DESCRIPTION
37 .BR sem_getvalue ()
38 places the current value of the semaphore pointed to
39 .I sem
40 into the integer pointed to by
41 .IR sval .
42 .PP
43 If one or more processes or threads are blocked
44 waiting to lock the semaphore with
45 .BR sem_wait (3),
46 POSIX.1 permits two possibilities for the value returned in
47 .IR sval :
48 either 0 is returned;
49 or a negative number whose absolute value is the count
50 of the number of processes and threads currently blocked in
51 .BR sem_wait (3).
52 Linux adopts the former behavior.
53 .SH RETURN VALUE
54 .BR sem_getvalue ()
55 returns 0 on success;
56 on error, \-1 is returned and
57 .I errno
58 is set to indicate the error.
59 .SH ERRORS
60 .TP
61 .B EINVAL
62 .I sem
63 is not a valid semaphore.
64 (The glibc implementation currently does not check whether
65 .I sem
66 is valid.)
67 .SH ATTRIBUTES
68 For an explanation of the terms used in this section, see
69 .BR attributes (7).
70 .ad l
71 .nh
72 .TS
73 allbox;
74 lbx lb lb
75 l l l.
76 Interface       Attribute       Value
78 .BR sem_getvalue ()
79 T}      Thread safety   MT-Safe
80 .TE
81 .hy
82 .ad
83 .sp 1
84 .SH CONFORMING TO
85 POSIX.1-2001, POSIX.1-2008.
86 .SH NOTES
87 The value of the semaphore may already have changed by the time
88 .BR sem_getvalue ()
89 returns.
90 .SH SEE ALSO
91 .BR sem_post (3),
92 .BR sem_wait (3),
93 .BR sem_overview (7)