MSGCTL(3P)
π MSGCTL(3P) β the POSIX Programmer's Manual one π
okay bestie, before we even get into it: this page lives in the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, go read the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. π
β¨ PROLOG β¨
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.
πΈ NAME πΈ
msgctl β XSI message control operations
π SYNOPSIS π
#include <sys/msg.h>
int msgctl(int msqid, int cmd, struct msqid_ds *buf);
π DESCRIPTION π
So msgctl() operates on XSI message queues (see the Base Definitions volume of POSIX.1β2017, Section 3.226, Message Queue). Lowkey important caveat though: it is unspecified whether this function interoperates with the realtime interprocess communication facilities defined in Section 2.8, Realtime. iykyk.
The msgctl() function shall provide message control operations as specified by cmd. And here are the values for cmd, plus the message control operations they specify:
IPC_STATβ places the current value of each member of themsqid_dsdata structure associated withmsqidinto the structure pointed to bybuf. The contents of this structure are defined in<sys/msg.h>. π«ΆIPC_SETβ sets the value of these members of themsqid_dsdata structure associated withmsqidto the corresponding value found in the structure pointed to bybuf:msg_perm.uidmsg_perm.gidmsg_perm.modemsg_qbytes
Also, the msg_ctime timestamp shall be set to the current time, as described in Section 2.7.1, IPC General Description.
IPC_SET can only be executed by a process with appropriate privileges or that has an effective user ID equal to the value of msg_perm.cuid or msg_perm.uid in the msqid_ds data structure associated with msqid. And heads up: only a process with appropriate privileges can raise the value of msg_qbytes. π₯
IPC_RMIDβ removes the message queue identifier specified bymsqidfrom the system and destroys the message queue andmsqid_dsdata structure associated with it.IPC_RMDcan only be executed by a process with appropriate privileges or one that has an effective user ID equal to the value ofmsg_perm.cuidormsg_perm.uidin themsqid_dsdata structure associated withmsqid.
π RETURN VALUE π
Upon successful completion, msgctl() shall return 0; otherwise, it shall return -1 and set errno to indicate the error. slay when it's zero, crying when it's not π
π ERRORS π
The msgctl() function shall fail if:
EACCESβ the argumentcmdisIPC_STATand the calling process does not have read permission; see Section 2.7, XSI Interprocess Communication.EINVALβ the value ofmsqidis not a valid message queue identifier; or the value ofcmdis not a valid command.EPERMβ the argumentcmdisIPC_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 ofmsg_perm.cuidormsg_perm.uidin the data structure associated withmsqid.EPERMβ the argumentcmdisIPC_SET, an attempt is being made to increase to the value ofmsg_qbytes, and the effective user ID of the calling process does not have appropriate privileges.
The following sections are informative. β¨ (yes bestie, the vibe shifts here)
π¦ EXAMPLES π¦
None.
π APPLICATION USAGE π
The POSIX Realtime Extension defines alternative interfaces for interprocess communication (IPC). 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. basically: future-proof ur code, bestie π§
β RATIONALE β
None.
πΈ FUTURE DIRECTIONS πΈ
None.
π₯ SEE ALSO π₯
Section 2.7, XSI Interprocess Communication, Section 2.8, Realtime, mq_close(), mq_getattr(), mq_notify(), mq_open(), mq_receive(), mq_send(), mq_setattr(), mq_unlink(), msgget(), msgrcv(), msgsnd()
The Base Definitions volume of POSIX.1β2017, Section 3.226, Message Queue, <sys_msg.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!! this one was brought to you by IEEE/The Open Group, dated 2017, filed under MSGCTL(3P) β go forth and control those message queues, you absolute icon ππ
π¦ 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