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, and errno gets 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 β€” name was 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms