1MSGGET(P) POSIX Programmer's Manual MSGGET(P)
2
3
4
6 msgget - get the XSI message queue identifier
7
9 #include <sys/msg.h>
10
11 int msgget(key_t key, int msgflg);
12
13
15 The msgget() function operates on XSI message queues (see the Base Def‐
16 initions volume of IEEE Std 1003.1-2001, Section 3.224, Message Queue).
17 It is unspecified whether this function interoperates with the realtime
18 interprocess communication facilities defined in Realtime .
19
20 The msgget() function shall return the message queue identifier associ‐
21 ated with the argument key.
22
23 A message queue identifier, associated message queue, and data struc‐
24 ture (see <sys/msg.h>), shall be created for the argument key if one of
25 the following is true:
26
27 * The argument key is equal to IPC_PRIVATE.
28
29 * The argument key does not already have a message queue identifier
30 associated with it, and (msgflg & IPC_CREAT) is non-zero.
31
32 Upon creation, the data structure associated with the new message queue
33 identifier shall be initialized as follows:
34
35 * msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid shall
36 be set equal to the effective user ID and effective group ID,
37 respectively, of the calling process.
38
39 * The low-order 9 bits of msg_perm.mode shall be set equal to the low-
40 order 9 bits of msgflg.
41
42 * msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime shall be
43 set equal to 0.
44
45 * msg_ctime shall be set equal to the current time.
46
47 * msg_qbytes shall be set equal to the system limit.
48
50 Upon successful completion, msgget() shall return a non-negative inte‐
51 ger, namely a message queue identifier. Otherwise, it shall return -1
52 and set errno to indicate the error.
53
55 The msgget() function shall fail if:
56
57 EACCES A message queue identifier exists for the argument key, but
58 operation permission as specified by the low-order 9 bits of
59 msgflg would not be granted; see XSI Interprocess Communication
60 .
61
62 EEXIST A message queue identifier exists for the argument key but
63 ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) is non-zero.
64
65 ENOENT A message queue identifier does not exist for the argument key
66 and (msgflg & IPC_CREAT) is 0.
67
68 ENOSPC A message queue identifier is to be created but the system-
69 imposed limit on the maximum number of allowed message queue
70 identifiers system-wide would be exceeded.
71
72
73 The following sections are informative.
74
76 None.
77
79 The POSIX Realtime Extension defines alternative interfaces for inter‐
80 process communication (IPC). Application developers who need to use IPC
81 should design their applications so that modules using the IPC routines
82 described in XSI Interprocess Communication can be easily modified to
83 use the alternative interfaces.
84
86 None.
87
89 None.
90
92 XSI Interprocess Communication , Realtime , mq_close() , mq_getattr() ,
93 mq_notify() , mq_open() , mq_receive() , mq_send() , mq_setattr() ,
94 mq_unlink() , msgctl() , msgrcv() , msgsnd() , the Base Definitions
95 volume of IEEE Std 1003.1-2001, <sys/msg.h>
96
98 Portions of this text are reprinted and reproduced in electronic form
99 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
100 -- Portable Operating System Interface (POSIX), The Open Group Base
101 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
102 Electrical and Electronics Engineers, Inc and The Open Group. In the
103 event of any discrepancy between this version and the original IEEE and
104 The Open Group Standard, the original IEEE and The Open Group Standard
105 is the referee document. The original Standard can be obtained online
106 at http://www.opengroup.org/unix/online.html .
107
108
109
110IEEE/The Open Group 2003 MSGGET(P)