1msgids(2) System Calls msgids(2)
2
3
4
6 msgids - discover all message queue identifiers
7
9 #include <sys/msg.h>
10
11 int msgids(int *buf, uint_t nids, uint_t *pnids);
12
13
15 The msgids() function copies all active message queue identifiers from
16 the system into the user-defined buffer specified by buf, provided that
17 the number of such identifiers is not greater than the number of inte‐
18 gers the buffer can contain, as specified by nids. If the size of the
19 buffer is insufficient to contain all of the active message queue iden‐
20 tifiers in the system, none are copied.
21
22
23 Whether or not the size of the buffer is sufficient to contain all of
24 them, the number of active message queue identifiers in the system is
25 copied into the unsigned integer pointed to by pnids.
26
27
28 If nids is 0 or less than the number of active message queue identi‐
29 fiers in the system, buf is ignored.
30
32 Upon successful completion, msgids() returns 0. Otherwise, −1 is
33 returned and errno is set to indicate the error.
34
36 The msgids() function will fail if:
37
38 EFAULT The buf or pnids argument points to an illegal address.
39
40
42 The msgids() function returns a snapshot of all the active message
43 queue identifiers in the system. More may be added and some may be
44 removed before they can be used by the caller.
45
47 Example 1 msgids() example
48
49
50 This is sample C code indicating how to use the msgids() function (see
51 msgsnap(2)):
52
53
54 void
55 examine_queues()
56 {
57 int *ids = NULL;
58 uint_t nids = 0;
59 uint_t n;
60 int i;
61
62 for (;;) {
63 if (msgids(ids, nids, &n) != 0) {
64 perror("msgids");
65 exit(1);
66 }
67 if (n <= nids) /* we got them all */
68 break;
69 /* we need a bigger buffer */
70 ids = realloc(ids, (nids = n) * sizeof (int));
71 }
72
73 for (i = 0; i < n; i++)
74 process_msgid(ids[i]);
75
76 free(ids);
77 }
78
79
81 See attributes(5) for descriptions of the following attributes:
82
83
84
85
86 ┌─────────────────────────────┬─────────────────────────────┐
87 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
88 ├─────────────────────────────┼─────────────────────────────┤
89 │MT-Level │Async-Signal-Safe │
90 └─────────────────────────────┴─────────────────────────────┘
91
93 ipcrm(1), ipcs(1), Intro(2), msgctl(2), msgget(2), msgsnap(2),
94 msgrcv(2), msgsnd(2), attributes(5)
95
96
97
98SunOS 5.11 8 Mar 2000 msgids(2)