1MSGGET(3P)                 POSIX Programmer's Manual                MSGGET(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       msgget — get the XSI message queue identifier
14

SYNOPSIS

16       #include <sys/msg.h>
17
18       int msgget(key_t key, int msgflg);
19

DESCRIPTION

21       The msgget() function operates on XSI message queues (see the Base Def‐
22       initions  volume of POSIX.1‐2008, Section 3.225, Message Queue).  It is
23       unspecified whether  this  function  interoperates  with  the  realtime
24       interprocess communication facilities defined in Section 2.8, Realtime.
25
26       The msgget() function shall return the message queue identifier associ‐
27       ated with the argument key.
28
29       A message queue identifier, associated message queue, and  data  struc‐
30       ture (see <sys/msg.h>), shall be created for the argument key if one of
31       the following is true:
32
33        *  The argument key is equal to IPC_PRIVATE.
34
35        *  The argument key does not already have a message  queue  identifier
36           associated with it, and (msgflg & IPC_CREAT) is non-zero.
37
38       Upon creation, the data structure associated with the new message queue
39       identifier shall be initialized as follows:
40
41        *  msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid  shall
42           be  set  to  the  effective user ID and effective group ID, respec‐
43           tively, of the calling process.
44
45        *  The low-order 9 bits of msg_perm.mode shall be set to the low-order
46           9 bits of msgflg.
47
48        *  msg_qnum,  msg_lspid,  msg_lrpid, msg_stime, and msg_rtime shall be
49           set to 0.
50
51        *  msg_ctime shall be set to the current time, as described in Section
52           2.7.1, IPC General Description.
53
54        *  msg_qbytes shall be set to the system limit.
55

RETURN VALUE

57       Upon  successful completion, msgget() shall return a non-negative inte‐
58       ger, namely a message queue identifier.  Otherwise, it shall return  −1
59       and set errno to indicate the error.
60

ERRORS

62       The msgget() function shall fail if:
63
64       EACCES A  message  queue  identifier  exists  for the argument key, but
65              operation permission as specified by the  low-order  9  bits  of
66              msgflg  would  not be granted; see Section 2.7, XSI Interprocess
67              Communication.
68
69       EEXIST A message queue identifier  exists  for  the  argument  key  but
70              ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) is non-zero.
71
72       ENOENT A  message  queue identifier does not exist for the argument key
73              and (msgflg & IPC_CREAT) is 0.
74
75       ENOSPC A message queue identifier is to  be  created  but  the  system-
76              imposed  limit  on  the  maximum number of allowed message queue
77              identifiers system-wide would be exceeded.
78
79       The following sections are informative.
80

EXAMPLES

82       None.
83

APPLICATION USAGE

85       The POSIX Realtime Extension defines alternative interfaces for  inter‐
86       process communication (IPC). Application developers who need to use IPC
87       should design their applications so that modules using the IPC routines
88       described  in Section 2.7, XSI Interprocess Communication can be easily
89       modified to use the alternative interfaces.
90

RATIONALE

92       None.
93

FUTURE DIRECTIONS

95       None.
96

SEE ALSO

98       Section 2.7, XSI Interprocess  Communication,  Section  2.8,  Realtime,
99       ftok(), mq_close(), mq_getattr(), mq_notify(), mq_open(), mq_receive(),
100       mq_send(), mq_setattr(), mq_unlink(), msgctl(), msgrcv(), msgsnd()
101
102       The Base Definitions volume of  POSIX.1‐2008,  Section  3.225,  Message
103       Queue, <sys_msg.h>
104
106       Portions  of  this text are reprinted and reproduced in electronic form
107       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
108       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
109       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
110       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
111       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
112       event of any discrepancy between this version and the original IEEE and
113       The Open Group Standard, the original IEEE and The Open Group  Standard
114       is  the  referee document. The original Standard can be obtained online
115       at http://www.unix.org/online.html .
116
117       Any typographical or formatting errors that appear  in  this  page  are
118       most likely to have been introduced during the conversion of the source
119       files to man page format. To report such errors,  see  https://www.ker
120       nel.org/doc/man-pages/reporting_bugs.html .
121
122
123
124IEEE/The Open Group                  2013                           MSGGET(3P)
Impressum