*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> msgget (2)              
Title
Content
Arch
Section
 

msgget(2)

Contents


NAME    [Toc]    [Back]

       msgget - Return (and possibly create) the ID for a message
       queue

SYNOPSIS    [Toc]    [Back]

       #include <sys/msg.h>

       int msgget(
               key_t key,
               int msgflg );

       Application developers may want to specify #include statements
 for <sys/types.h> and <sys/ipc.h> before the one for
       <sys/msg.h> if programs are being developed  for  multiple
       platforms.   The  additional  #include  statements are not
       required on Tru64 UNIX systems or by ISO or  X/Open  standards,
  but may be required on other vendors' systems that
       conform to these standards.

STANDARDS    [Toc]    [Back]

       Interfaces documented on this reference  page  conform  to
       industry standards as follows:

       msgget():  XSH4.0, XSH4.2, XSH5.0

       Refer to the standards(5) reference page for more information
 about industry standards and associated tags.

PARAMETERS    [Toc]    [Back]

       Specifies the key that identifies the message  queue.  The
       value for the key parameter can be IPC_PRIVATE or a random
       number other than zero (0). To ensure  that  the  msgget()
       function  returns  a  new  message  queue  ID, specify the
       IPC_PRIVATE keyword.  Specifies  flags  that  control  the
       msgget()  function. Possible values are as follows: Specifies
 creating a message queue ID.

              If the specified key does not exist,  the  msgget()
              function  creates a message queue ID and associates
              it with the specified key.

              If the specified key does exist,  and  IPC_EXCL  is
              not  set, the msgget() function returns the message
              queue ID associated with key.

              If the specified key does  exist  and  IPC_EXCL  is
              set,  the  msgget()  function  fails and returns an
              error.  Specifies that you want to ensure that your
              application is the only one using the specified key
              parameter. If the specified key already exists, the
              msgget()  function fails and returns an error notification.

DESCRIPTION    [Toc]    [Back]

       The msgget() function returns the message queue ID for the
       message  queue  identified  by  the key parameter.  If the
       message queue ID does not  exist,  the  msgget()  function
       attempts to create it.

       If  you  specify  IPC_PRIVATE  for  the key parameter, the
       msgget() function returns the ID for a private  (that  is,
       newly created) message queue.

       The  msgflg  parameter  supplies  creation options for the
       msgget() function. The IPC_CREAT flag specifies  that  you
       want  the kernel to create a message queue for your application.
 The kernel returns the message queue  ID  to  your
       application  as the return value of the successful call to
       the msgget() function.

       The msgget() function does not create a message  queue  ID
       for  your  application  under  the following conditions: A
       message queue ID that is associated with the specified key
       already  exists.  In  this  case,  the  msgget()  function
       returns the message  queue  ID  associated  with  the  key
       parameter  (unless  you  have set the IPC_EXCL flag).  You
       have set the IPC_EXCL  flag  and  another  application  is
       using  the specified key. In this case, the msgget() function
 fails and returns an error to your application.

       After creating a new message queue ID, the msgget()  function
  initializes  the  msqid_ds structure associated with
       the ID as follows: The msg_perm.cuid and msg_perm.uid members
 are set equal to the effective user ID of the calling
       process.  The msg_perm.cgid and msg_perm.gid  members  are
       set  equal  to  the effective group ID of the calling process.
  The low-order nine bits of the msg_perm.mode member
       are  set  equal to the low-order nine bits of msgflg.  The
       msg_qnum, msg_lspid, msg_lrpid, msg_stime,  and  msg_rtime
       members  are  all set equal to zero.  The msg_ctime member
       is set equal to the current time.  The  msg_qbytes  member
       is set equal to the system limit.

RETURN VALUES    [Toc]    [Back]

       Upon  successful completion, the msgget() function returns
       a  message  queue  identifier.  Otherwise,  the   function
       returns  a  value  of  -1  and  sets errno to indicate the
       error.

ERRORS    [Toc]    [Back]

       The msgget() function sets errno to the  specified  values
       for  the  following conditions: A message queue identifier
       exists for the key parameter, but the calling process does
       not  have the appropriate privileges to perform the operation.
 The permission is specified by  the  low-order  nine
       bits  of the msgflg parameter.  A message queue identifier
       exists for the  key  parameter,  and  both  IPC_CREAT  and
       IPC_EXCL  are  set.   A  message queue identifier does not
       exist for the key parameter and the IPC_CREAT value is not
       set.   A  message queue identifier can be created, but the
       system-imposed limit on the maximum number of allowed message
 queue identifiers has been exceeded.

SEE ALSO    [Toc]    [Back]

      
      
       Functions:   msgctl(2),  msgrcv(2),  msgsnd(2),  table(2),
       ftok(3)

       Data Structures: msqid_ds(4)

       Standards: standards(5)



                                                        msgget(2)
[ Back ]
 Similar pages
Name OS Title
semget Tru64 Return (and possibly create) a semaphore ID
shmget Tru64 Return (and possibly create) the ID for a shared memory region
mq_open IRIX open/create a message queue
mq_open HP-UX create/open a message queue
mq_open Tru64 Establishes the connection between a message queue and a message queue descriptor (P1003.1b)
open Linux open and possibly create a file or device
mq_receive Tru64 Receives the oldest, highest-priority message from the message queue (P1003.1b)
mq_send Tru64 Places a message in the message queue (P1003.1b)
mq_receive HP-UX receive a message from a message queue
msgsnd OpenBSD send a message to a message queue
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service