sys_shm.h(7POSIX)

πŸ’– sys/shm.h β€” XSI shared memory facility πŸ’–

okay bestie, so this page is from the POSIX Programmer's Manual (the 7POSIX section, iykyk). Before we even start, real talk:

Heads up: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. Not me being dramatic, that's just what it says. πŸ™ˆ

✨ NAME ✨

sys/shm.h β€” the XSI shared memory facility, aka the place where processes share memory and become besties 🫢


🌸 SYNOPSIS 🌸

#include <sys/shm.h>

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so the <sys/shm.h> header shall define these symbolic constants, no cap:

  • SHM_RDONLY β€” attach read-only (otherwise it's read-write, bestie)
  • SHM_RND β€” round the attach address to SHMLBA
  • SHMLBA β€” segment low boundary address multiple

Then it shall define the following data types through typedef:

  • shmatt_t β€” an unsigned integer used for the number of current attaches, and it must be able to store values at least as large as a unsigned short. so like, big enough, okay?? πŸ’…

And it shall define the shmid_ds structure, which shall include these members:

struct ipc_perm shm_perm   Operation permission structure.
size_t          shm_segsz  Size of segment in bytes.
pid_t           shm_lpid   Process ID of last shared memory operation.
pid_t           shm_cpid   Process ID of creator.
shmatt_t        shm_nattch Number of current attaches.
time_t          shm_atime  Time of last shmat().
time_t          shm_dtime  Time of last shmdt().
time_t          shm_ctime  Time of last change by shmctl().

The <sys/shm.h> header shall define the pid_t, size_t, and time_t types exactly as described in <sys/types.h>. periodt.

The following shall be declared as functions β€” and bestie, they may also be defined as macros, so don't come for me when they are. Function prototypes shall be provided:

void *shmat(int, const void *, int);
int   shmctl(int, int, struct shmid_ds *);
int   shmdt(const void *);
int   shmget(key_t, size_t, int);

In addition, the <sys/shm.h> header shall include the <sys/ipc.h> header. it's giving family reunion 🌈

The following sections are informative. (so like, bonus content, not the rules-rules)


πŸŽ€ APPLICATION USAGE πŸŽ€

None. literally nothing. iconic of it honestly. πŸ’€


🧚 RATIONALE 🧚

None. also nothing. she said "no thoughts, head empty" πŸ’œ


πŸ¦‹ FUTURE DIRECTIONS πŸ¦‹

None. the future is… also nothing. slay.


⭐ SEE ALSO ⭐

  • <sys_ipc.h>
  • <sys_types.h>
  • The System Interfaces volume of POSIX.1‐2017: shmat(), shmctl(), shmdt(), shmget()

okay this part is the legal text and I am NOT paraphrasing legal text, bestie, so here it is exactly as it comes:

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 one's brought to you by IEEE/The Open Group, 2017, and the page is literally called sys_shm.h(7POSIX) β€” go share some memory with someone you love. mwah πŸ’‹