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

NAME

6       shmctl - shared memory control operations
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/ipc.h>
11       #include <sys/shm.h>
12
13       int shmctl(int shmid, int cmd, struct shmid_ds *buf);
14
15

DESCRIPTION

17       The shmctl() function provides a variety of shared memory control oper‐
18       ations as specified by cmd. The permission required for a shared memory
19       control  operation is given as {token}, where token is the type of per‐
20       mission needed. The types of permission are interpreted as follows:
21
22         00400    READ by user
23         00200    WRITE by user
24         00040    READ by group
25         00020    WRITE by group
26         00004    READ by others
27         00002    WRITE by others
28
29
30
31       See the Shared Memory Operation Permissions  section  of  Intro(2)  for
32       more information.
33
34
35       The following operations require the specified tokens:
36
37       IPC_STAT      Place the current value of each member of the data struc‐
38                     ture associated with shmid into the structure pointed  to
39                     by  buf.  The  contents  of this structure are defined in
40                     Intro(2). {READ}
41
42
43       IPC_SET       Set the value of the following members of the data struc‐
44                     ture  associated  with  shmid  to the corresponding value
45                     found in the structure pointed to by buf:
46
47                       shm_perm.uid
48                       shm_perm.gid
49                       shm_perm.mode  /* access permission bits only */
50
51                     This command can be executed only by a process  that  has
52                     appropriate  privileges  or an effective user ID equal to
53                     the value of shm_perm.cuid or  shm_perm.uid in  the  data
54                     structure associated with shmid.
55
56
57       IPC_RMID      Remove  the  shared  memory identifier specified by shmid
58                     from the system. The segment referenced by the identifier
59                     will  be  destroyed  when  all processes with the segment
60                     attached have either detached the segment or  exited.  If
61                     the  segment is not attached to any process when IPC_RMID
62                     is invoked, it will be destroyed immediately.  This  com‐
63                     mand can be executed only by a process that has appropri‐
64                     ate privileges or an effective user ID equal to the value
65                     of  shm_perm.cuid  or  shm_perm.uid in the data structure
66                     associated with shmid.
67
68
69       SHM_LOCK      Lock the shared memory segment specified by shmid in mem‐
70                     ory.  This command can be executed only by a process that
71                     has appropriate privileges.
72
73
74       SHM_UNLOCK    Unlock the shared memory segment specified by shmid. This
75                     command can be executed only by a process that has appro‐
76                     priate privileges.
77
78
79
80       A shared memory segment  must  be  explicitly  removed  using  IPC_RMID
81       before the system can deallocate it and the resources it uses.
82

RETURN VALUES

84       Upon  successful  completion,  0 is returned. Otherwise, −1 is returned
85       and errno is set to indicate the error.
86

ERRORS

88       The shmctl() function will fail if:
89
90       EACCES       The cmd argument is equal to IPC_STAT and {READ} operation
91                    permission is denied to the calling process.
92
93
94       EFAULT       The buf argument points to an illegal address.
95
96
97       EINVAL       The  shmid  argument  is not a valid shared memory identi‐
98                    fier; or the cmd argument is not a  valid  command  or  is
99                    IPC_SET and shm_perm.uid or shm_perm.gid is not valid.
100
101
102       ENOMEM       The  cmd  argument  is  equal to SHM_LOCK and there is not
103                    enough memory, or the operation would exceed  a  limit  or
104                    resource control on locked memory.
105
106
107       EOVERFLOW    The  cmd  argument is IPC_STAT and uid or gid is too large
108                    to be stored in the structure pointed to by buf.
109
110
111       EPERM        The cmd argument is equal  to  IPC_RMID  or  IPC_SET,  the
112                    effective  user  ID of the calling process is not equal to
113                    the value of shm_perm.cuid or  shm_perm.uid  in  the  data
114                    structure  associated  with shmid, and {PRIV_IPC_OWNER} is
115                    not asserted in the effective set of the calling process.
116
117                    The cmd argument is equal to SHM_LOCK  or  SHM_UNLOCK  and
118                    {PRIV_PROC_LOCK_MEMORY}  is  not asserted in the effective
119                    set of the calling process.
120
121

ATTRIBUTES

123       See attributes(5) for descriptions of the following attributes:
124
125
126
127
128       ┌─────────────────────────────┬─────────────────────────────┐
129       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
130       ├─────────────────────────────┼─────────────────────────────┤
131       │Interface Stability          │Standard                     │
132       └─────────────────────────────┴─────────────────────────────┘
133

SEE ALSO

135       ipcs(1), Intro(2), shmget(2), shmop(2),  attributes(5),  privileges(5),
136       standards(5)
137
138
139
140SunOS 5.11                        10 Apr 2007                        shmctl(2)
Impressum