sem_unlink(3)
β¨ NAME β¨
okay so bestie, meet sem_unlink β the function that removes a named semaphore. that's it, that's the whole job description π
π LIBRARY π
she lives in the POSIX threads library β that's libpthread, and when you're compiling you link her in with -lpthread. no cap.
πΈ SYNOPSIS πΈ
#include <semaphore.h>
int sem_unlink(const char *name);
π DESCRIPTION π
so like, sem_unlink() removes the named semaphore that name is pointing at. and the way she does it? the semaphore name gets removed immediately β instantly, no waiting around, main character energy fr fr.
but here's the part that's giving β¨actual OS behaviorβ¨: the semaphore itself isn't fully gone just because the name dipped. the semaphore gets destroyed only once all the other processes that have it open have closed it. so it's like, she leaves the group chat but the chat history stays until everybody else leaves too π iconic tbh.
π RETURN VALUE π
- all good? she returns
0. slay. - something went wrong? she returns
-1, anderrnogets set to tell you exactly what the drama was.
π ERRORS π
EACCESβ bestie you don't have permission to unlink this semaphore. not your house, not your rules πENAMETOOLONGβnamewas too long. girl, that name was doing the most, she could not fit.ENOENTβ there is no semaphore with the given name. you're looking for something that literally does not exist π
π ATTRIBUTES π
the whole rundown of what these terms even mean lives in attributes(7) β go peek if you're curious π¦
so for this one:
- Interface:
sem_unlink() - Attribute: Thread safety
- Value:
MT-Safe
translation: MT-Safe means she's multithread-safe, and yes that's a flex πͺ
π STANDARDS π
POSIX.1-2008. periodt.
π¦ HISTORY π¦
she's been around since POSIX.1-2001. a true veteran, an OG, we stan a legacy queen β
π SEE ALSO π
π and that's the whole page bestie! go forth and unlink responsibly π«Ά
Linux man-pages 6.20 Β· 2026-02-08 β mwah, ty for reading, ily, bye πβ¨π
π¦ where this page comes from
- 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 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2006, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms