SHM_UNLINK(3P)
π SHM_UNLINK(3P) π
okay so bestie, welcome to the POSIX Programmer's Manual β this is the page for shm_unlink, and it's giving "delete the name, not the vibe" β¨
πΈ PROLOG πΈ
Real talk before we start: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. No cap, check your local manpage first, bestie. π«Ά
β¨ NAME β¨
shm_unlink β remove a shared memory object (REALTIME) π
π¦ SYNOPSIS π¦
#include <sys/mman.h>
int shm_unlink(const char *name);
π DESCRIPTION π
So shm_unlink() shall remove the name of the shared memory object named by the string pointed to by name. That's it, that's the job. π§
But here's the iconic part: if one or more references to the shared memory object exist when the object is unlinked, the name shall be removed before shm_unlink() returns β but the removal of the memory object contents shall be postponed until all open and map references to the shared memory object have been removed. It's a slow goodbye. The name dips immediately, the memory sticks around until the last one leaves. π
And even if the object continues to exist after the last shm_unlink(), reuse of the name shall subsequently cause shm_open() to behave as if no shared memory object of this name exists β that is, shm_open() will fail if O_CREAT is not set, or will create a new shared memory object if O_CREAT is set. Fresh start energy, fr fr. π
β RETURN VALUE β
Upon successful completion, a value of zero shall be returned. Slay. β
Otherwise, a value of -1 shall be returned and errno set to indicate the error. And if -1 is returned, the named shared memory object shall not be changed by this function call. So if it goes wrong, nothing happened. No half-committed mess. We love a clean rollback. π
π ERRORS π
The shm_unlink() function shall fail if:
EACCESβ Permission is denied to unlink the named shared memory object. Bestie, you do not have the keys to this one. π«ENOENTβ The named shared memory object does not exist. Nothing there. Ghosted you. π»
The shm_unlink() function may fail if:
ENAMETOOLONGβ The length of thenameargument exceeds{_POSIX_PATH_MAX}on systems that do not support the XSI option or exceeds{_XOPEN_PATH_MAX}on XSI systems, or has a pathname component that is longer than{_POSIX_NAME_MAX}on systems that do not support the XSI option or longer than{_XOPEN_NAME_MAX}on XSI systems. And here's the little footnote you need: a call toshm_unlink()with anameargument that contains the same shared memory object name as was previously used in a successfulshm_open()call shall not give an[ENAMETOOLONG]error. π
The following sections are informative. (iykyk β informational, not normative π )
π EXAMPLES π
None. Yeah. Nothing. We're on our own, bestie. π
πΈ APPLICATION USAGE πΈ
Names of memory objects that were allocated with open() are deleted with unlink() in the usual fashion. Names of memory objects that were allocated with shm_open() are deleted with shm_unlink(). Two doors, two keys, don't mix them up. π«Ά
Note that the actual memory object is not destroyed until the last close and unmap on it have occurred if it was already in use. Last one out turns off the lights. β
π RATIONALE π
None. Truly nothing to say. Silence is golden. β¨
π₯ FUTURE DIRECTIONS π₯
A future version might require the shm_open() and shm_unlink() functions to have semantics similar to normal file system operations. Might. Watch this space, bestie. π
π SEE ALSO π
close()mmap()munmap()shmat()shmctl()shmdt()shm_open()
The Base Definitions volume of POSIX.1β2017, <sys_mman.h> π
π COPYRIGHT π
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 β brought to you by IEEE/The Open Group, 2017, landing in your terminal as SHM_UNLINK(3P). Go unlink something (responsibly). π
β¨
π¦ 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