Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ msgget(2) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

msgctl

msgrcv

msgsnd

msgxrcv

ftok

dstables

msgget

Purpose

     Gets a message queue identifier.

Syntax

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

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

Description

     The msgget system call  returns the message queue identi-
     fier associated  with the specified key.   The key param-
     eter  is  either the  value  IPC_PRIVATE  or an  IPC  key
     constructed by the ftok subroutine (or by a similar algo-
     rithm).  See "ftok" for details about this subroutine.

     If Distributed Services is  installed on your system, the
     msgget  system call  provides  access to  both local  and
     remote queues.

     The msgflg  parameter is constructed by  logically OR-ing
     one or more of the following values:

     IPC_CREAT    Creates the  data structure  if it  does not
                  already exist.
     IPC_EXCL     Causes  the msgget  system call  to fail  if
                  IPC_CREAT is also set and the data structure
                  already exists.
     S_IRUSR      Permits  the  process  that  owns  the  data
                  structure to read it.
     S_IWUSR      Permits  the  process  that  owns  the  data
                  structure to modify it.
     S_IRGRP      Permits the  group associated with  the data
                  structure to read it.
     S_IWGRP      Permits the  group associated with  the data
                  structure to modify it.
     S_IROTH      Permits others to read the data structure.
     S_IWOTH      Permits others to modify the data structure.

     The  values  that begin  with  S_I-  are defined  in  the
     sys/stat.h header  file and  are a  subset of  the access
     permissions that apply to files.

     A message  queue identifier and associated  message queue
     and data structure  are created for the value  of the key
     parameter if one of the following are true:

     o   key is equal to IPC_PRIVATE.

     o   key does not already  have a message queue identifier
         associated with it, and IPC_CREAT is set.

     Upon creation, the data structure associated with the new
     message queue identifier is initialized as follows:

     o   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.

     o   The  low-order nine  bits  of  msg_perm.mode are  set
         equal to the low-order nine bits of the msgflg param-
         eter.

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

     o   msg_ctime is set equal to the current time.

     o   msg_qbytes is set equal to the system limit.

     The msgget system call performs the following actions:

     1.  First, msgget looks in the IPC key mapping tables for
         key.

     2.  If  the tables  do not  have an  entry for  key, then
         msgget  either finds  or  creates  (depending on  the
         value of msgflg) a local queue with key.

     3.  If the tables indicate that  key has been mapped to a
         new key at a remote  node and you have installed Dis-
         tributed Services, then msgget:

         o   Allocates a local header for the remote queue.

         o   Queries the remote node to find or create a queue
             with the indicated key.

         o   Installs the information (handle, boot count, and
             so on) returned by the remote node into the local
             header.

     4.  Finally,  msgget returns  the ID  of the  local queue
         header to its caller.

     For an explanation  of how to set up local  to remote key
     mappings,  see  the  dstables command  in  AIX  Operating
     System Commands Reference.

Return Value

     Upon successful completion, a message queue identifier is
     returned.  If the msgget system call fails, a value of -1
     is returned and errno is set to indicate the error.

Diagnostics

     The msgget system  call fails if one or more  of the fol-
     lowing are true:

     EACCES     A message queue identifier  exists for the key
                parameter but  operation permission  as speci-
                fied by the low-order  nine bits of the msgflg
                parameter would not be granted.

     ENOENT     A message queue identifier  does not exist for
                the key parameter and IPC_CREAT is not set.

     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.

     EEXIST     A message queue identifier exists for key, and
                both IPC_CREAT and IPC_EXCL are set.

     If  Distributed Services  is  installed  on your  system,
     msgget can also fail if one  or more of the following are
     true:

     EDIST         The   server   has  blocked   new   inbound
                   requests.

     EDIST         Outbound requests are currently blocked.

     EDIST         The server has a  release level of Distrib-
                   uted Services that  cannot communicate with
                   this node.

     EAGAIN        The  server  is  too  busy  to  accept  the
                   request.

     ENOMEM        Either  this node  or the  server does  not
                   have enough memory available to service the
                   request.

     EPERM         The translate tables of  the server did not
                   contain any entry  for either the effective
                   user  ID  or  effective  group  ID  of  the
                   calling process.

     ENOCONNECT    An attempt to establish  a new network con-
                   nection with a remote node failed.

     EBADCONNECT   An attempt to use  an existing network con-
                   nection with a remote node failed.

Related Information

     In this book:   "msgctl," "msgrcv," "msgsnd,"  "msgxrcv,"
     and "ftok."

     The  dstables command  in AIX  Operating System  Commands
     Reference.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026