Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Linux System Call-msgget function details-Linux general technology-Linux programming and kernel information, the following is a detailed description. Function Description:
Gets the ID of the Message Queue associated with a key. There are two scenarios in which a message queue is created:
1. If the key value is IPC_PRIVATE.
2. Alternatively, the key value is not IPC_PRIVATE, and the message queue corresponding to the key does not exist, and IPC_CREAT is specified in the flag.
If a new message queue is created, the msqid_ds data structure associated with it is initialized as follows:
Msg_perm.cuid and msg_perm.uid are valid user IDs of callers;
Msg_perm.cgid and msg_perm.gid are valid user group logos of callers;
Msg_perm.mode: The minimum nine digits are set to the lowest nine digits of msgflg;
Msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are set to 0;
Msg_ctime is set to the current time;
Msg_qbytes is set to MSGMNB.
Int msgget (key_t key, int msgflg );
Key: The key associated with the message queue.
Msgflg: indicates the establishment and access permissions of message queues.
If the message queue is successfully executed, the Message Queue id value is returned. -1 is returned for failure, and errno is set to one of the following values
EACCES: the specified message queue already exists, but the calling process does not have the permission to access it and does not have the CAP_IPC_OWNER permission.
EEXIST: The Message Queue specified by the key already exists, while IPC_CREAT and IPC_EXCL are both specified in msgflg.
ENOENT: The Message Queue specified by the key does not exist. The IPC_CREAT flag is not specified in msgflg.
ENOMEM: A Message Queue needs to be created, but the memory is insufficient.
ENOSPC: A Message Queue needs to be created, but the system limit has been reached.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.