SEM_GETVALUE(3P)
π SEM_GETVALUE(3P) β the POSIX Programmer's Manual page, but make it make sense π
okay bestie, welcome to SEM_GETVALUE(3P) from the POSIX Programmer's Manual. pull up a chair, grab a boba, we're gonna read a manpage together π§β¨
πΈ PROLOG πΈ
okay so real talk first: this page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the tea on Linux behavior), or honestly the interface may not even be implemented on Linux at all. π no cap, just how it is.
β¨ NAME β¨
sem_getvalue β get the value of a semaphore π
π SYNOPSIS π
#include <semaphore.h>
int sem_getvalue(sem_t *restrict sem, int *restrict sval);
π¦ DESCRIPTION π¦
so here's the vibe. the sem_getvalue() function shall update the location referenced by the sval argument to have the value of the semaphore referenced by sem β and it does this without affecting the state of the semaphore. like, it's a look, not a touch. no side effects, we're just peeking π
here's the catch tho, and it's giving "time is a construct": the updated value represents an actual semaphore value that occurred at some unspecified time during the call, but it need not be the actual value of the semaphore when it is returned to the calling process. so likeβ¦ it was true at some point. iconic. unreliable narrator energy fr fr π
and if sem is locked, then the object that sval points to shall either be set to zero, or be set to a negative number whose absolute value represents the number of processes waiting for the semaphore at some unspecified time during the call. two valid answers, no in-between drama. π
β RETURN VALUE β
- on a successful completion,
sem_getvalue()shall return a value ofzero. slay. π«Ά - otherwise it shall return a value of
-1and seterrnoto indicate the error. not slay. π
π ERRORS π
the sem_getvalue() function may fail if:
EINVALβ thesemargument does not refer to a valid semaphore.
heads up bestie: the following sections are informative. (translation: they're vibes, not requirements.)
π EXAMPLES π
None. β yes literally, there are none. the void. nothing. we move. π
π APPLICATION USAGE π
None. β again, nothing here. short king section. π
π§ RATIONALE π§
None. β nope, they didn't give us one. mystery behavior, and honestly? we respect it. β¨
π FUTURE DIRECTIONS π
None. β no future plans announced. it's just gonna keep on doing its thing. periodt.
π₯ SEE ALSO π₯
semctl()semget()semop()sem_post()sem_timedwait()sem_trywait()
also the Base Definitions volume of POSIX.1β2017, <semaphore.h> π
π COPYRIGHT π
okay legal moment, stay with me, this matters:
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. (so if we ever disagree, they win, no debate π«‘) The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie π this was SEM_GETVALUE(3P) from IEEE/The Open Group, 2017 β go forth and read your semaphores without fear, you absolute main character π¦πβ¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms