]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it) |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
bea08fec | 25 | .\" FIXME . There is now duplication of some of the information |
c533af9d | 26 | .\" below in semctl.2, msgctl.2, and shmctl.2 -- MTK, Nov 04 |
5dfa5152 | 27 | .\" |
bea08fec | 28 | .\" FIXME . Ultimately, there should probably be |
f1bf4c8c | 29 | .\" svmq_overview(7), svshm_overview(7), and svsem_overview(7) |
5dfa5152 MK |
30 | .\" that provide an overview of each System V IPC mechanism. |
31 | .\" In that case: | |
32 | .\" * Those files should add a discussion of the /proc/sysvipc | |
33 | .\" interfaces. | |
34 | .\" * Documentation of the various /proc interfaces should move into | |
35 | .\" those files (from proc(5)), and references in the various *.2 | |
36 | .\" pages that refer to the /proc files should be adjusted. | |
24610092 | 37 | .\" * The only part that uniquely belongs in svipc(7) is perhaps |
5dfa5152 MK |
38 | .\" the discussion of ipc_perm. |
39 | .\" | |
97986708 | 40 | .TH SVIPC 7 2016-03-15 "Linux" "Linux Programmer's Manual" |
fea681da | 41 | .SH NAME |
2c5e151c | 42 | svipc \- System V interprocess communication mechanisms |
fea681da MK |
43 | .SH SYNOPSIS |
44 | .nf | |
c8250206 MK |
45 | .B #include <sys/msg.h> |
46 | .B #include <sys/sem.h> | |
47 | .B #include <sys/shm.h> | |
48 | .fi | |
fea681da MK |
49 | .SH DESCRIPTION |
50 | This manual page refers to the Linux implementation of the System V | |
ab35dd1f | 51 | interprocess communication (IPC) mechanisms: |
fea681da MK |
52 | message queues, semaphore sets, and shared memory segments. |
53 | In the following, the word | |
f19a0f03 | 54 | .I resource |
fea681da | 55 | means an instantiation of one among such mechanisms. |
c634028a | 56 | .SS Resource access permissions |
fea681da | 57 | For each resource, the system uses a common structure of type |
0daa9e92 | 58 | .I "struct ipc_perm" |
fea681da | 59 | to store information needed in determining permissions to perform an |
ab35dd1f | 60 | IPC operation. |
fea681da | 61 | The |
bb38b71d | 62 | .I ipc_perm |
548be2a6 | 63 | structure includes the following members: |
088a639b | 64 | .in +4n |
bb38b71d MK |
65 | .nf |
66 | ||
67 | struct ipc_perm { | |
aeb4b1fc MK |
68 | uid_t cuid; /* creator user ID */ |
69 | gid_t cgid; /* creator group ID */ | |
70 | uid_t uid; /* owner user ID */ | |
71 | gid_t gid; /* owner group ID */ | |
72 | unsigned short mode; /* r/w permissions */ | |
bb38b71d MK |
73 | }; |
74 | .fi | |
75 | .in | |
fea681da MK |
76 | .PP |
77 | The | |
bb38b71d | 78 | .I mode |
fea681da | 79 | member of the |
bb38b71d | 80 | .I ipc_perm |
fea681da | 81 | structure defines, with its lower 9 bits, the access permissions to the |
ab35dd1f | 82 | resource for a process executing an IPC system call. |
fea681da MK |
83 | The permissions are interpreted as follows: |
84 | .sp | |
85 | .nf | |
bb38b71d MK |
86 | 0400 Read by user. |
87 | 0200 Write by user. | |
fea681da | 88 | .sp .5 |
bb38b71d MK |
89 | 0040 Read by group. |
90 | 0020 Write by group. | |
fea681da | 91 | .sp .5 |
bb38b71d MK |
92 | 0004 Read by others. |
93 | 0002 Write by others. | |
fea681da MK |
94 | .fi |
95 | .PP | |
96 | Bits 0100, 0010, and 0001 (the execute bits) are unused by the system. | |
97 | Furthermore, | |
98 | "write" | |
99 | effectively means | |
100 | "alter" | |
101 | for a semaphore set. | |
102 | .PP | |
103 | The same system header file also defines the following symbolic | |
104 | constants: | |
105 | .TP 14 | |
106 | .B IPC_CREAT | |
107 | Create entry if key doesn't exist. | |
108 | .TP | |
109 | .B IPC_EXCL | |
110 | Fail if key exists. | |
111 | .TP | |
112 | .B IPC_NOWAIT | |
113 | Error if request must wait. | |
114 | .TP | |
115 | .B IPC_PRIVATE | |
116 | Private key. | |
117 | .TP | |
118 | .B IPC_RMID | |
119 | Remove resource. | |
120 | .TP | |
121 | .B IPC_SET | |
122 | Set resource options. | |
123 | .TP | |
124 | .B IPC_STAT | |
125 | Get resource options. | |
126 | .PP | |
127 | Note that | |
128 | .B IPC_PRIVATE | |
129 | is a | |
bb38b71d | 130 | .I key_t |
fea681da MK |
131 | type, while all the other symbolic constants are flag fields and can |
132 | be OR'ed into an | |
9ff08aad | 133 | .I int |
fea681da | 134 | type variable. |
c634028a | 135 | .SS Message queues |
fea681da MK |
136 | A message queue is uniquely identified by a positive integer |
137 | .RI "(its " msqid ) | |
138 | and has an associated data structure of type | |
8478ee02 | 139 | .IR "struct msqid_ds" , |
fea681da MK |
140 | defined in |
141 | .IR <sys/msg.h> , | |
142 | containing the following members: | |
088a639b | 143 | .in +4n |
bb38b71d MK |
144 | .nf |
145 | ||
146 | struct msqid_ds { | |
147 | struct ipc_perm msg_perm; | |
b14178d5 MK |
148 | msgqnum_t msg_qnum; /* no of messages on queue */ |
149 | msglen_t msg_qbytes; /* bytes max on a queue */ | |
150 | pid_t msg_lspid; /* PID of last msgsnd(2) call */ | |
151 | pid_t msg_lrpid; /* PID of last msgrcv(2) call */ | |
152 | time_t msg_stime; /* last msgsnd(2) time */ | |
153 | time_t msg_rtime; /* last msgrcv(2) time */ | |
154 | time_t msg_ctime; /* last change time */ | |
bb38b71d MK |
155 | }; |
156 | .fi | |
157 | .in | |
fea681da | 158 | .TP 11 |
bb38b71d MK |
159 | .I msg_perm |
160 | .I ipc_perm | |
fea681da MK |
161 | structure that specifies the access permissions on the message |
162 | queue. | |
163 | .TP | |
bb38b71d | 164 | .I msg_qnum |
fea681da MK |
165 | Number of messages currently on the message queue. |
166 | .TP | |
bb38b71d | 167 | .I msg_qbytes |
fea681da MK |
168 | Maximum number of bytes of message text allowed on the message |
169 | queue. | |
170 | .TP | |
bb38b71d | 171 | .I msg_lspid |
fea681da | 172 | ID of the process that performed the last |
63f6a20a | 173 | .BR msgsnd (2) |
fea681da MK |
174 | system call. |
175 | .TP | |
bb38b71d | 176 | .I msg_lrpid |
fea681da | 177 | ID of the process that performed the last |
63f6a20a | 178 | .BR msgrcv (2) |
fea681da MK |
179 | system call. |
180 | .TP | |
bb38b71d | 181 | .I msg_stime |
fea681da | 182 | Time of the last |
63f6a20a | 183 | .BR msgsnd (2) |
fea681da MK |
184 | system call. |
185 | .TP | |
bb38b71d | 186 | .I msg_rtime |
fea681da | 187 | Time of the last |
1bdcbc01 | 188 | .BR msgrcv (2) |
fea681da MK |
189 | system call. |
190 | .TP | |
bb38b71d | 191 | .I msg_ctime |
fea681da MK |
192 | Time of the last |
193 | system call that changed a member of the | |
bb38b71d | 194 | .I msqid_ds |
fea681da | 195 | structure. |
c634028a | 196 | .SS Semaphore sets |
fea681da MK |
197 | A semaphore set is uniquely identified by a positive integer |
198 | .RI "(its " semid ) | |
199 | and has an associated data structure of type | |
8478ee02 | 200 | .IR "struct semid_ds" , |
fea681da MK |
201 | defined in |
202 | .IR <sys/sem.h> , | |
203 | containing the following members: | |
088a639b | 204 | .in +4n |
bb38b71d MK |
205 | .nf |
206 | ||
207 | struct semid_ds { | |
208 | struct ipc_perm sem_perm; | |
209 | time_t sem_otime; /* last operation time */ | |
210 | time_t sem_ctime; /* last change time */ | |
aeb4b1fc | 211 | unsigned long sem_nsems; /* count of sems in set */ |
bb38b71d MK |
212 | }; |
213 | .fi | |
214 | .in | |
fea681da | 215 | .TP 11 |
bb38b71d MK |
216 | .I sem_perm |
217 | .I ipc_perm | |
fea681da MK |
218 | structure that specifies the access permissions on the semaphore |
219 | set. | |
220 | .TP | |
bb38b71d | 221 | .I sem_otime |
fea681da | 222 | Time of last |
63f6a20a | 223 | .BR semop (2) |
fea681da MK |
224 | system call. |
225 | .TP | |
bb38b71d | 226 | .I sem_ctime |
fea681da | 227 | Time of last |
63f6a20a | 228 | .BR semctl (2) |
fea681da MK |
229 | system call that changed a member of the above structure or of one |
230 | semaphore belonging to the set. | |
231 | .TP | |
bb38b71d | 232 | .I sem_nsems |
fea681da | 233 | Number of semaphores in the set. |
2fda57bd | 234 | Each semaphore of the set is referenced by a nonnegative integer |
fea681da MK |
235 | ranging from |
236 | .B 0 | |
237 | to | |
bb38b71d | 238 | .IR sem_nsems\-1 . |
fea681da MK |
239 | .PP |
240 | A semaphore is a data structure of type | |
8478ee02 | 241 | .I "struct sem" |
fea681da | 242 | containing the following members: |
088a639b | 243 | .in +4n |
bb38b71d | 244 | .nf |
44b41c64 | 245 | |
bb38b71d MK |
246 | struct sem { |
247 | int semval; /* semaphore value */ | |
9b4a382a | 248 | int sempid; /* PID of process that last modified */ |
aeb4b1fc MK |
249 | .\" unsigned short semncnt; /* nr awaiting semval to increase */ |
250 | .\" unsigned short semzcnt; /* nr awaiting semval = 0 */ | |
59220720 | 251 | }; |
bb38b71d MK |
252 | .fi |
253 | .in | |
fea681da | 254 | .TP 11 |
bb38b71d | 255 | .I semval |
2fda57bd | 256 | Semaphore value: a nonnegative integer. |
fea681da | 257 | .TP |
bb38b71d | 258 | .I sempid |
9b4a382a MK |
259 | PID of the last process that modified the value of |
260 | this semaphore. | |
ae7098c7 | 261 | .\".TP |
bb38b71d | 262 | .\".I semncnt |
ae7098c7 | 263 | .\"Number of processes suspended awaiting for |
bb38b71d | 264 | .\".I semval |
ae7098c7 MK |
265 | .\"to increase. |
266 | .\".TP | |
bb38b71d | 267 | .\".I semznt |
ae7098c7 | 268 | .\"Number of processes suspended awaiting for |
bb38b71d | 269 | .\".I semval |
ae7098c7 | 270 | .\"to become zero. |
c634028a | 271 | .SS Shared memory segments |
fea681da MK |
272 | A shared memory segment is uniquely identified by a positive integer |
273 | .RI "(its " shmid ) | |
274 | and has an associated data structure of type | |
8478ee02 | 275 | .IR "struct shmid_ds" , |
fea681da MK |
276 | defined in |
277 | .IR <sys/shm.h> , | |
278 | containing the following members: | |
088a639b | 279 | .in +4n |
bb38b71d MK |
280 | .nf |
281 | ||
282 | struct shmid_ds { | |
283 | struct ipc_perm shm_perm; | |
b14178d5 MK |
284 | size_t shm_segsz; /* size of segment */ |
285 | pid_t shm_cpid; /* PID of creator */ | |
286 | pid_t shm_lpid; /* PID, last operation */ | |
287 | shmatt_t shm_nattch; /* no. of current attaches */ | |
288 | time_t shm_atime; /* time of last attach */ | |
289 | time_t shm_dtime; /* time of last detach */ | |
290 | time_t shm_ctime; /* time of last change */ | |
bb38b71d MK |
291 | }; |
292 | .fi | |
293 | .in | |
fea681da | 294 | .TP 11 |
bb38b71d MK |
295 | .I shm_perm |
296 | .I ipc_perm | |
fea681da MK |
297 | structure that specifies the access permissions on the shared memory |
298 | segment. | |
299 | .TP | |
bb38b71d | 300 | .I shm_segsz |
fea681da MK |
301 | Size in bytes of the shared memory segment. |
302 | .TP | |
bb38b71d | 303 | .I shm_cpid |
fea681da MK |
304 | ID of the process that created the shared memory segment. |
305 | .TP | |
bb38b71d | 306 | .I shm_lpid |
fea681da | 307 | ID of the last process that executed a |
63f6a20a | 308 | .BR shmat (2) |
fea681da | 309 | or |
63f6a20a | 310 | .BR shmdt (2) |
fea681da MK |
311 | system call. |
312 | .TP | |
bb38b71d | 313 | .I shm_nattch |
fea681da MK |
314 | Number of current alive attaches for this shared memory segment. |
315 | .TP | |
bb38b71d | 316 | .I shm_atime |
fea681da | 317 | Time of the last |
63f6a20a | 318 | .BR shmat (2) |
fea681da MK |
319 | system call. |
320 | .TP | |
bb38b71d | 321 | .I shm_dtime |
fea681da | 322 | Time of the last |
63f6a20a | 323 | .BR shmdt (2) |
fea681da MK |
324 | system call. |
325 | .TP | |
bb38b71d | 326 | .I shm_ctime |
fea681da | 327 | Time of the last |
63f6a20a | 328 | .BR shmctl (2) |
fea681da | 329 | system call that changed |
bb38b71d | 330 | .IR shmid_ds . |
eb25716f MK |
331 | .SS IPC namespaces |
332 | For a discussion of the interaction of System V IPC objects and | |
333 | IPC namespaces, see | |
334 | .BR namespaces (7). | |
47297adb | 335 | .SH SEE ALSO |
02e306d9 MK |
336 | .BR ipcmk (1), |
337 | .BR ipcrm (1), | |
338 | .BR ipcs (1), | |
c9eeaf2a | 339 | .BR lsipc (1), |
305db6d8 | 340 | .BR ipc (2), |
fea681da MK |
341 | .BR msgctl (2), |
342 | .BR msgget (2), | |
343 | .BR msgrcv (2), | |
344 | .BR msgsnd (2), | |
345 | .BR semctl (2), | |
346 | .BR semget (2), | |
347 | .BR semop (2), | |
348 | .BR shmat (2), | |
349 | .BR shmctl (2), | |
350 | .BR shmdt (2), | |
351 | .BR shmget (2), | |
4effb5be MK |
352 | .BR ftok (3), |
353 | .BR namespaces (7) |