Linux System Call-msgget function details

Source: Internet
Author: User
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.

Usage:
# Include
# Include
# Include

Int msgget (key_t key, int msgflg );

Parameters:
Key: The key associated with the message queue.
Msgflg: indicates the establishment and access permissions of message queues.

Return description:
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.
Related Article

Contact Us

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.