1msgget(2) System Calls msgget(2)
2
3
4
6 msgget - get message queue
7
9 #include <sys/msg.h>
10
11 int msgget(key_t key, int msgflg);
12
13
15 The msgget() argument returns the message queue identifier associated
16 with key.
17
18
19 A message queue identifier and associated message queue and data struc‐
20 ture (see Intro(2)) are created for key if one of the following are
21 true:
22
23 o key is IPC_PRIVATE.
24
25 o key does not already have a message queue identifier associ‐
26 ated with it, and (msgflg&IPC_CREAT) is true.
27
28
29 On creation, the data structure associated with the new message queue
30 identifier is initialized as follows:
31
32 o msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid
33 are set to the effective user ID and effective group ID,
34 respectively, of the calling process.
35
36 o The low-order 9 bits of msg_perm.mode are set to the low-
37 order 9 bits of msgflg.
38
39 o msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are
40 set to 0.
41
42 o msg_ctime is set to the current time.
43
44 o msg_qbytes is set to the system limit. See NOTES.
45
47 Upon successful completion, a non-negative integer representing a mes‐
48 sage queue identifier is returned. Otherwise, −1 is returned and errno
49 is set to indicate the error.
50
52 The msgget() function will fail if:
53
54 EACCES A message queue identifier exists for key, but operation per‐
55 mission (see Intro(2)) as specified by the low-order 9 bits
56 of msgflg would not be granted.
57
58
59 EEXIST A message queue identifier exists for key but
60 (msgflg&IPC_CREAT) and (msgflg&IPC_EXCL) are both true.
61
62
63 ENOENT A message queue identifier does not exist for key and
64 (msgflg&IPC_CREAT) is false.
65
66
67 ENOSPC A message queue identifier is to be created but the system-
68 imposed limit on the maximum number of allowed message queue
69 identifiers system wide would be exceeded. See NOTES.
70
71
73 See attributes(5) for descriptions of the following attributes:
74
75
76
77
78 ┌─────────────────────────────┬─────────────────────────────┐
79 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
80 ├─────────────────────────────┼─────────────────────────────┤
81 │Interface Stability │Standard │
82 └─────────────────────────────┴─────────────────────────────┘
83
85 rctladm(1M), Intro(2), msgctl(2), msgrcv(2), msgsnd(2), setrctl(2),
86 ftok(3C), attributes(5), standards(5)
87
89 The system-defined limit used to initialize msg_qbytes is the minimum
90 enforced value of the calling process's process.max-msg-qbytes resource
91 control.
92
93
94 The system-imposed limit on the number of message queue identifiers is
95 maintained on a per-project basis using the project.max-msg-ids
96 resource control. The zone.max-msg-ids resource control restricts the
97 total amount of message queue identifiers that can be allocated by a
98 zone.
99
100
101 See rctladm(1M) and setrctl(2) for information about using resource
102 controls.
103
104
105
106SunOS 5.11 14 Aug 2006 msgget(2)