MSGGET(2) 21 January 1990 MSGGET(2)

NAME

msgget - get message queue

SYNOPSIS

#include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h>

int msgget(key, msgflg) key_t key; int msgflg;

DESCRIPTION

msgget() returns the message queue identifier associated with key.

A message queue identifier and associated message queue and data structure (see intro(2)) are created for key() if one of the following is true:

  • key is equal to IPC_PRIVATE.

  • key does not already have a message queue identifier associated with it, and IPC_CREAT) is ``true''.
  • Upon creation, the data structure associated with the new message queue identifier is initialized as follows:

  • msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid are set equal to the effective user ID and effective group ID, respectively, of the calling process.

  • The low-order 9 bits of msg_perm.mode are set equal to the low-order 9 bits of msgflg.

  • msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are set equal to 0.

  • msg_ctime is set equal to the current time.

  • msg_qbytes is set equal to the system-wide standard value of the maximum number of bytes allowed on a message queue.
  • A message queue identifier (msqid) is a unique positive integer created by a msgget(2) system call. Each msqid has a message queue and a data structure associated with it. The data structure is referred to as msqid_ds() and contains the following members:

    struct ipc_perm msg_perm; /** operation permission struct **/ ushort msg_qnum; /** number of msgs on q **/ ushort msg_qbytes; /** max number of bytes on q **/ ushort msg_lspid; /** pid of last msgsnd operation **/ ushort msg_lrpid; /** pid of last msgrcv operation **/ time_t msg_stime; /** last msgsnd time **/ time_t msg_rtime; /** last msgrcv time **/ time_t msg_ctime; /** last change time **/
    /** Times measured in secs since **/
    /** 00:00:00 GMT+1, Jan. 1, 1970 **/

    msg_perm() is an ipc_perm structure that specifies the message operation permission (see below). This structure includes the following members:

    ushort cuid; /** creator user id **/ ushort cgid; /** creator group id **/ ushort uid; /** user id **/ ushort gid; /** group id **/ ushort mode; /** r/w permission **/

    msg_qnum is the number of messages currently on the queue. msg_qbytes is the maximum number of bytes allowed on the queue. msg_lspid is the process ID of the last process that performed a msgsnd operation. msg_lrpid is the process ID of the last process that performed a msgrcv operation. msg_stime is the time of the last msgsnd operation, msg_rtime is the time of the last msgrcv operation, and msg_ctime is the time of the last msgctl(2) operation that changed a member of the above structure.

    RETURN

    msgget() returns A non-negative message queue identifier on success. On failure, it returns -1 and sets errno to indicate the error.

    ERRORS

    EACCES
    A message queue identifier exists for key, but operation permission (see intro(2)) as specified by the low-order 9 bits of msgflg would not be granted.

    EEXIST
    A message queue identifier exists for key() but IPC_CREATSfR) & (msgflg & IPC_EXCLSfR)) is ``true''.

    ENOENT
    A message queue identifier does not exist for key() and IPC_CREAT) is ``false''.

    ENOSPC
    A message queue identifier is to be created but the system-imposed limit on the maximum number of allowed message queue identifiers system wide would be exceeded.

    SEE

    intro(2), msgctl(2), msgop(2)

    MSGGET(2) 21 January 1990 MSGGET(2)

    Manpage converter © AXL