1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
3 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" FIXME . There is now duplication of some of the information
26 .\" below in semctl.2, msgctl.2, and shmctl.2 -- MTK, Nov 04
28 .\" FIXME . Ultimately, there should probably be
29 .\" svmq_overview(7), svshm_overview(7), and svsem_overview(7)
30 .\" that provide an overview of each System V IPC mechanism.
32 .\" * Those files should add a discussion of the /proc/sysvipc
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.
37 .\" * The only part that uniquely belongs in svipc(7) is perhaps
38 .\" the discussion of ipc_perm.
40 .TH SVIPC 7 2016-03-15 "Linux" "Linux Programmer's Manual"
42 svipc \- System V interprocess communication mechanisms
45 .B #include <sys/msg.h>
46 .B #include <sys/sem.h>
47 .B #include <sys/shm.h>
50 This manual page refers to the Linux implementation of the System V
51 interprocess communication (IPC) mechanisms:
52 message queues, semaphore sets, and shared memory segments.
53 In the following, the word
55 means an instantiation of one among such mechanisms.
56 .SS Resource access permissions
57 For each resource, the system uses a common structure of type
59 to store information needed in determining permissions to perform an
63 structure includes the following members:
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 */
81 structure defines, with its lower 9 bits, the access permissions to the
82 resource for a process executing an IPC system call.
83 The permissions are interpreted as follows:
96 Bits 0100, 0010, and 0001 (the execute bits) are unused by the system.
103 The same system header file also defines the following symbolic
107 Create entry if key doesn't exist.
113 Error if request must wait.
122 Set resource options.
125 Get resource options.
131 type, while all the other symbolic constants are flag fields and can
136 A message queue is uniquely identified by a positive integer
138 and has an associated data structure of type
139 .IR "struct msqid_ds" ,
142 containing the following members:
147 struct ipc_perm msg_perm;
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 */
161 structure that specifies the access permissions on the message
165 Number of messages currently on the message queue.
168 Maximum number of bytes of message text allowed on the message
172 ID of the process that performed the last
177 ID of the process that performed the last
193 system call that changed a member of the
197 A semaphore set is uniquely identified by a positive integer
199 and has an associated data structure of type
200 .IR "struct semid_ds" ,
203 containing the following members:
208 struct ipc_perm sem_perm;
209 time_t sem_otime; /* last operation time */
210 time_t sem_ctime; /* last change time */
211 unsigned long sem_nsems; /* count of sems in set */
218 structure that specifies the access permissions on the semaphore
229 system call that changed a member of the above structure or of one
230 semaphore belonging to the set.
233 Number of semaphores in the set.
234 Each semaphore of the set is referenced by a nonnegative integer
240 A semaphore is a data structure of type
242 containing the following members:
247 int semval; /* semaphore value */
248 int sempid; /* PID of process that last modified */
249 .\" unsigned short semncnt; /* nr awaiting semval to increase */
250 .\" unsigned short semzcnt; /* nr awaiting semval = 0 */
256 Semaphore value: a nonnegative integer.
259 PID of the last process that modified the value of
263 .\"Number of processes suspended awaiting for
268 .\"Number of processes suspended awaiting for
271 .SS Shared memory segments
272 A shared memory segment is uniquely identified by a positive integer
274 and has an associated data structure of type
275 .IR "struct shmid_ds" ,
278 containing the following members:
283 struct ipc_perm shm_perm;
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 */
297 structure that specifies the access permissions on the shared memory
301 Size in bytes of the shared memory segment.
304 ID of the process that created the shared memory segment.
307 ID of the last process that executed a
314 Number of current alive attaches for this shared memory segment.
329 system call that changed
332 For a discussion of the interaction of System V IPC objects and