]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/sem_getvalue.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / sem_getvalue.3
CommitLineData
2c731798
MK
1'\" t
2.\" Hey Emacs! This file is -*- nroff -*- source.
3.\"
4.\" Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net>
5.\"
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
c13182ef 14.\"
2c731798
MK
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
c13182ef
MK
18.\" the use of the information contained herein.
19.\"
2c731798
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.TH SEM_GETVALUE 3 2006-03-25 "Linux 2.6.16" "Linux Programmer's Manual"
24.SH NAME
25sem_getvalue \- get the value of a semaphore
26.SH SYNOPSIS
27.nf
28.B #include <semaphore.h>
29.sp
30.BI "int sem_getvalue(sem_t *" sem ", int *" sval );
31.fi
32.SH DESCRIPTION
33.BR sem_getvalue ()
34places the current value of the semaphore pointed to
35.I sem
36into the integer pointed to by
37.IR sval .
38
c13182ef 39If one or more processes or threads are blocked
2c731798
MK
40waiting to lock the semaphore with
41.BR sem_wait (3),
c13182ef 42POSIX.1-2001 permits two possibilities for the value returned in
4509e795 43.IR sval :
c13182ef
MK
44either 0 is returned;
45or a negative number whose absolute value is the count
2c731798
MK
46of the number of processes and threads currently blocked in
47.BR sem_wait (3).
48Linux adopts the former behaviour.
49.SH RETURN VALUE
50.BR sem_getvalue ()
c13182ef 51returns 0 on success;
2c731798 52on error, \-1 is returned and
c13182ef 53.I errno
2c731798
MK
54is set to indicate the error.
55.SH ERRORS
56.TP
57.B EINVAL
58.I sem
59is not a valid semaphore.
60.SH NOTES
61The value of the semaphore may already have changed by the time
62.BR sem_getvalue ()
63returns.
64.SH CONFORMING TO
65POSIX.1-2001.
66.SH "SEE ALSO"
67.BR sem_post (3),
68.BR sem_wait (3),
69.BR sem_overview (7)