SHMCTL(3P)
π SHMCTL(3P) β bestie edition π
okay so this one is from the POSIX Programmer's Manual, page SHMCTL(3P), and we're about to get so into shared memory control. grab a snack. π
π«Ά PROLOG
real talk first: this manual 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 deets on Linux behavior), or honestly the interface may not be implemented on Linux at all. not me warning you up front π
β¨ NAME β¨
shmctl β XSI shared memory control operations. yes bestie, it's giving "I manage your shared memory segments." π
πΈ SYNOPSIS πΈ
#include <sys/shm.h>
int shmctl(int shmid, int cmd, struct shmid_ds *buf);
π¦ DESCRIPTION π¦
so the shmctl() function operates on XSI shared memory (peep the Base Definitions volume of POSIX.1β2017, Section 3.346, Shared Memory Object). and here's a lil caveat: it is unspecified whether this function interoperates with the realtime interprocess communication facilities defined in Section 2.8, Realtime. like, nobody's promising anything there. π
shmctl() provides a whole variety of shared memory control operations, and which one you get is decided by cmd. here are the values for cmd that are available:
IPC_STATβ place the current value of each member of theshmid_dsdata structure associated withshmidinto the structure pointed to bybuf. the contents of that structure are defined in<sys/shm.h>. she's reading the receipts. πIPC_SETβ set the value of the following members of theshmid_dsdata structure associated withshmidto the corresponding value found in the structure pointed to bybuf:shm_perm.uidshm_perm.gidshm_perm.modeβ low-order nine bits.
also, the shm_ctime timestamp shall be set to the current time, as described in Section 2.7.1, IPC General Description.
IPC_SETcan only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value ofshm_perm.cuidorshm_perm.uidin theshmid_dsdata structure associated withshmid. no random walk-ins allowed. π«
IPC_RMIDβ remove the shared memory identifier specified byshmidfrom the system and destroy the shared memory segment and theshmid_dsdata structure associated with it.IPC_RMIDcan only be executed by a process that has an effective user ID equal to either that of a process with appropriate privileges or to the value ofshm_perm.cuidorshm_perm.uidin theshmid_dsdata structure associated withshmid.
π this one deletes the whole thing. it's not a soft delete, it's not a "oops undo", it's gone gone. permissions check first, always.
π RETURN VALUE π
upon successful completion, shmctl() shall return 0. otherwise, it shall return -1 and set errno to indicate the error. classic 0-or-1 behavior, love that for her. β¨
π ERRORS π
the shmctl() function shall fail if:
EACCESβ the argumentcmdis equal toIPC_STATand the calling process does not have read permission; see Section 2.7, XSI Interprocess Communication. like, you didn't have the read perms, bestie. πEINVALβ the value ofshmidis not a valid shared memory identifier, or the value ofcmdis not a valid command. something in there is fake. πEPERMβ the argumentcmdis equal toIPC_RMIDorIPC_SETand the effective user ID of the calling process is not equal to that of a process with appropriate privileges and it is not equal to the value ofshm_perm.cuidorshm_perm.uidin the data structure associated withshmid. who are you and why are you touching this. π«
the shmctl() function may fail if:
EOVERFLOWβ thecmdargument isIPC_STATand thegidoruidvalue is too large to be stored in the structure pointed to by thebufargument. too much. won't fit. she's overflowing. π
the following sections are informative, so like, bonus lore. π
πΈ EXAMPLES πΈ
None. nothing. empty. the void. π³οΈ (iconic of them honestly)
π APPLICATION USAGE π
the POSIX Realtime Extension defines alternative interfaces for interprocess communication. application developers who need to use IPC should design their applications so that modules using the IPC routines described in Section 2.7, XSI Interprocess Communication can be easily modified to use the alternative interfaces. future-proofing is the vibe check here, fr fr. π§
π RATIONALE π
None. nope. nada. she said no comment. π
π¦ FUTURE DIRECTIONS π¦
None. nothing planned. staying exactly as she is. periodt. π
β SEE ALSO β
- Section 2.7, XSI Interprocess Communication
- Section 2.8, Realtime
shmat()shmdt()shmget()shm_open()shm_unlink()- The Base Definitions volume of POSIX.1β2017, Section 3.346, Shared Memory Object
<sys_shm.h>
go read the friends, bestie. the whole friend group is slaying. π«Ά
π 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, page SHMCTL(3P). mwah. π go manage some shared memory responsibly, ily. πβ¨
π¦ 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