SEM_DESTROY(3POSIX)
π SEM_DESTROY(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual β yes this is SEM_DESTROY(3POSIX), and yes it's about semaphores, and yes we're gonna make it make sense. π
lowkey important heads-up before anything else: this page lives in the POSIX Programmer's Manual, and the Linux implementation of this interface may differ β so pls consult the corresponding Linux manual page for the actual Linux behavior. also possible: the interface might not even be implemented on Linux at all. π check before you ship, fr fr.
β¨ NAME β¨
sem_destroy β destroy an unnamed semaphore π«Ά
πΈ SYNOPSIS πΈ
#include <semaphore.h>
int sem_destroy(sem_t *sem);
π¦ DESCRIPTION π¦
so, sem_destroy() destroys the unnamed semaphore indicated by sem. that's the whole vibe. π
now here's the tea, and it's important tea: only a semaphore that was created using sem_init() may be destroyed using sem_destroy(). if you call sem_destroy() on a named semaphore? the effect is undefined. not "probably fine", not "works on my machine" β undefined. π«
also, after you destroy it, using sem again is undefined until it gets reinitialized by another call to sem_init(). so like... it's giving β¨goneβ¨ until you bring it back properly.
it is safe to destroy an initialized semaphore when no threads are currently blocked on it. π
but the effect of destroying a semaphore while other threads are currently blocked on it? undefined. do not do that. that's not main character energy, that's a crash arc. π
π RETURN VALUE π
- on a successful completion, a value of zero shall be returned. slay. β¨
- otherwise, a value of
-1shall be returned anderrnogets set to indicate the error. π
π ERRORS π
the sem_destroy() function may fail if:
EINVALβ thesemargument is not a valid semaphore. π©EBUSYβ there are currently processes blocked on the semaphore. π¬
ngl bestie, the following sections are informative. so like, they're context, not gospel. π
π EXAMPLES π
None. π
π APPLICATION USAGE π
None. π«Ά
π§ RATIONALE π§
None. β¨
β FUTURE DIRECTIONS β
None. πΈ
π SEE ALSO π
semctl()semget()semop()sem_init()sem_open()
also the Base Definitions volume of POSIX.1β2017, <semaphore.h> π
π COPYRIGHT π
okay legal moment, stay with me, this part 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. 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 has been IEEE/The Open Group, 2017, signing off from SEM_DESTROY(3POSIX). go destroy ur semaphores responsibly, mwah ππ
β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms