sys_shm.h(0P)

🌸 sys_shm.h(0P) β€” bestie edition 🌸

okay so real talk, this one's a page from the POSIX Programmer's Manual β€” it's sys_shm.h(0P), the XSI shared memory facility header. it's giving "header file lore" and honestly? kind of iconic. πŸ’…


✨ PROLOG ✨

so this manual page is literally part of the POSIX Programmer's Manual, periodt. but β€” and this is the important bit, bestie β€” the Linux implementation of this interface may differ, so you gotta consult the corresponding Linux manual page for details on Linux behavior. OR, plot twist, the interface may just... not be implemented on Linux at all. πŸ™ˆ vibe check accordingly.


πŸŽ€ NAME πŸŽ€

sys/shm.h β€” the XSI shared memory facility. that's it, that's the name. short, sweet, main character energy. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/shm.h>

just one include line. lowkey elegant. ✨


πŸ’œ DESCRIPTION πŸ’œ

okay so the <sys/shm.h> header shall define the following symbolic constants:

  • SHM_RDONLY β€” attach read-only (else it's read-write). read-only girlies rise 🫢
  • SHM_RND β€” round the attach address to SHMLBA.
  • SHMLBA β€” segment low boundary address multiple.

then, through typedef, <sys/shm.h> shall define these data types:

  • 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 type unsigned short. no overflow shenanigans, we don't do that here. 😭

and now the moment you've all been waiting for... πŸ₯ the <sys/shm.h> header shall define the shmid_ds structure, which shall include the following 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().

look at that little struct. so organized. so slay. πŸ‘‘

the <sys/shm.h> header shall define the pid_t, size_t, and time_t types exactly as described in <sys/types.h> β€” no reinventing the wheel, we borrow from the neighbors. 🌈

now, the following shall be declared as functions and may also be defined as macros. 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);

four little functions, all lined up, all perfect. ⭐

and IN ADDITION, the <sys/shm.h> header shall include the <sys/ipc.h> header. it's a package deal, iykyk. πŸ’«

πŸ’€ heads up bestie: the following sections are informative. that means they're the chill, non-binding part of the page.

🌸 APPLICATION USAGE 🌸

None. literally nothing. the section said "no thoughts, head empty." πŸŽ€


🧚 RATIONALE 🧚

None. also nothing. we're keeping it mysterious. πŸ’…


⭐ FUTURE DIRECTIONS ⭐

None. the future is unwritten, babe. πŸ¦‹


πŸ”₯ SEE ALSO πŸ”₯

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

go read those next, they're the sequels. πŸ‘‘


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.

⚠️ and this part MATTERS: 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 was brought to you by IEEE/The Open Group, 2017 β€” yeah that's the footer, we're folding it in like a little bow πŸŽ€ β€” so go forth and attach some shared memory, you absolute icon. mwah. πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from