1shmids(2)                        System Calls                        shmids(2)
2
3
4

NAME

6       shmids - discover all shared memory identifiers
7

SYNOPSIS

9       #include <sys/shm.h>
10
11       int shmids(int *buf, uint_t nids, uint_t *pnids);
12
13

DESCRIPTION

15       The  shmids() function copies all active shared memory 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 shared memory 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 shared memory 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  shared  memory  identi‐
29       fiers in the system, buf is ignored.
30

RETURN VALUES

32       Upon  successful  completion,  shmids()  returns  0.   Otherwise, −1 is
33       returned and errno is set to indicate the error.
34

ERRORS

36       The shmids() function will fail if:
37
38       EFAULT    The buf or pnids argument points to an illegal address.
39
40

USAGE

42       The shmids() function returns a snapshot of all the active shared  mem‐
43       ory  identifiers  in  the  system.   More  may be added and some may be
44       removed before they can be used by the caller.
45

EXAMPLES

47       Example 1 shmids() example
48
49
50       This is sample C code indicating how to use the shmids() function.
51
52
53         void
54         examine_shmids()
55         {
56              int *ids = NULL;
57              uint_t nids = 0;
58              uint_t n;
59              int i;
60
61              for (;;) {
62                   if (shmids(ids, nids, &n) != 0) {
63                        perror("shmids");
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_shmid(ids[i]);
74
75              free(ids);
76         }
77
78

ATTRIBUTES

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

SEE ALSO

92       ipcrm(1),   ipcs(1),   Intro(2),   shmctl(2),   shmget(2),    shmop(2),
93       attributes(5)
94
95
96
97SunOS 5.11                        8 Mar 2000                         shmids(2)
Impressum