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