sys_msg.h(7POSIX)

πŸ’– sys_msg.h β€” XSI message queue structures πŸ’–

okay bestie, so this one is sys_msg.h from the POSIX Programmer's Manual (that's the 7POSIX section of the manual, iykyk) and it's literally the header that defines all the XSI message queue stuff. it's giving ✨ infrastructure ✨ and honestly? we're obsessed.


πŸŽ€ PROLOG πŸŽ€

so 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, bestie), or β€” and this is the messy part β€” the interface may not be implemented on Linux <em>at all</em>. πŸ’€


✨ NAME ✨

sys/msg.h β€” XSI message queue structures πŸ¦‹


🌸 SYNOPSIS 🌸

#include <sys/msg.h>

πŸ’… DESCRIPTION πŸ’…

okay so the <sys/msg.h> header shall define the following data types, and it does it through typedef:

  • msgqnum_t β€” used for the number of messages in the message queue. πŸ”’
  • msglen_t β€” used for the number of bytes allowed in a message queue. πŸ“

and these types? they shall be unsigned integer types that are able to store values at least as large as a type unsigned short. so they're not playing around, they can hold a whole unsigned short's worth of numbers minimum, periodt. πŸ’ͺ


the <sys/msg.h> header shall also define the following symbolic constant as a message operation flag:

  • MSG_NOERROR β€” no error if big message. (yes that's literally the description. no error if big message. iconic brevity. πŸ‘‘)

then we get the msqid_ds structure, which shall include these members, and bestie there are eight of them:

struct ipc_perm msg_perm   Operation permission structure.
msgqnum_t       msg_qnum   Number of messages currently on queue.
msglen_t        msg_qbytes Maximum number of bytes allowed on queue.
pid_t           msg_lspid  Process ID of last msgsnd().
pid_t           msg_lrpid  Process ID of last msgrcv().
time_t          msg_stime  Time of last msgsnd().
time_t          msg_rtime  Time of last msgrcv().
time_t          msg_ctime  Time of last change.

let's break the vibe check down one by one 🫢

  • struct ipc_perm msg_perm β€” the operation permission structure. who's allowed to do what πŸ‘€
  • msgqnum_t msg_qnum β€” number of messages currently on queue. the count, live, right now.
  • msglen_t msg_qbytes β€” maximum number of bytes allowed on queue. the ceiling, the limit, the "don't test me" number.
  • pid_t msg_lspid β€” process ID of the last msgsnd().
  • pid_t msg_lrpid β€” process ID of the last msgrcv().
  • time_t msg_stime β€” time of the last msgsnd().
  • time_t msg_rtime β€” time of the last msgrcv().
  • time_t msg_ctime β€” time of the last change. ⏰

the <sys/msg.h> header shall define the pid_t, size_t, ssize_t, and time_t types as described in <sys/types.h>. so like, they're defined there, this header just knows about them, no cap. 🌈


and the following shall be declared as functions, and may also be defined as macros β€” function prototypes shall be provided:

int       msgctl(int, int, struct msqid_ds *);
int       msgget(key_t, int);
ssize_t   msgrcv(int, void *, size_t, long, int);
int       msgsnd(int, const void *, size_t, int);

four functions, four absolutely load-bearing little guys πŸ”₯


plus (and this is the bonus round), the <sys/msg.h> header shall include the <sys/ipc.h> header. headers including headers, it's a whole family tree. 🧚

⚠️ heads up: the following sections are informative. not normative, just vibes.

πŸ™ˆ APPLICATION USAGE πŸ™ˆ

none. that's it. nothing. empty. the void. 😭


πŸ’œ RATIONALE πŸ’œ

none. again! nothing! the girlies said "no notes" and meant it. πŸ’€


🌟 FUTURE DIRECTIONS 🌟

none. (three for three, bestie. the future is a mystery and this page is not about to speculate.) ✨


πŸ” SEE ALSO πŸ”

  • <sys_ipc.h>
  • <sys_types.h>
  • The System Interfaces volume of POSIX.1‐2017: msgctl(), msgget(), msgrcv(), msgsnd()

like yeah go read those too, they're the sequel. πŸ“š


okay so this is the part where we give credit, and credit is due:

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 <strong>the referee document</strong>. 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 .


🫢 okay that's the whole page bestie!! this one's brought to you by IEEE/The Open Group, dated 2017, and it lives at sys_msg.h(7POSIX). slay, go queue some messages, ily πŸ’–βœ¨πŸŽ€