]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/svipc.7
mdoc.7: Add a cross-reference to groff_mdoc(7)
[thirdparty/man-pages.git] / man7 / svipc.7
CommitLineData
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 42svipc \- 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
50This manual page refers to the Linux implementation of the System V
ab35dd1f 51interprocess communication (IPC) mechanisms:
fea681da
MK
52message queues, semaphore sets, and shared memory segments.
53In the following, the word
f19a0f03 54.I resource
fea681da 55means an instantiation of one among such mechanisms.
c634028a 56.SS Resource access permissions
fea681da 57For each resource, the system uses a common structure of type
0daa9e92 58.I "struct ipc_perm"
fea681da 59to store information needed in determining permissions to perform an
ab35dd1f 60IPC operation.
fea681da 61The
bb38b71d 62.I ipc_perm
548be2a6 63structure includes the following members:
088a639b 64.in +4n
bb38b71d
MK
65.nf
66
67struct 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
77The
bb38b71d 78.I mode
fea681da 79member of the
bb38b71d 80.I ipc_perm
fea681da 81structure defines, with its lower 9 bits, the access permissions to the
ab35dd1f 82resource for a process executing an IPC system call.
fea681da
MK
83The 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
96Bits 0100, 0010, and 0001 (the execute bits) are unused by the system.
97Furthermore,
98"write"
99effectively means
100"alter"
101for a semaphore set.
102.PP
103The same system header file also defines the following symbolic
104constants:
105.TP 14
106.B IPC_CREAT
107Create entry if key doesn't exist.
108.TP
109.B IPC_EXCL
110Fail if key exists.
111.TP
112.B IPC_NOWAIT
113Error if request must wait.
114.TP
115.B IPC_PRIVATE
116Private key.
117.TP
118.B IPC_RMID
119Remove resource.
120.TP
121.B IPC_SET
122Set resource options.
123.TP
124.B IPC_STAT
125Get resource options.
126.PP
127Note that
128.B IPC_PRIVATE
129is a
bb38b71d 130.I key_t
fea681da
MK
131type, while all the other symbolic constants are flag fields and can
132be OR'ed into an
9ff08aad 133.I int
fea681da 134type variable.
c634028a 135.SS Message queues
fea681da
MK
136A message queue is uniquely identified by a positive integer
137.RI "(its " msqid )
138and has an associated data structure of type
8478ee02 139.IR "struct msqid_ds" ,
fea681da
MK
140defined in
141.IR <sys/msg.h> ,
142containing the following members:
088a639b 143.in +4n
bb38b71d
MK
144.nf
145
146struct 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
161structure that specifies the access permissions on the message
162queue.
163.TP
bb38b71d 164.I msg_qnum
fea681da
MK
165Number of messages currently on the message queue.
166.TP
bb38b71d 167.I msg_qbytes
fea681da
MK
168Maximum number of bytes of message text allowed on the message
169queue.
170.TP
bb38b71d 171.I msg_lspid
fea681da 172ID of the process that performed the last
63f6a20a 173.BR msgsnd (2)
fea681da
MK
174system call.
175.TP
bb38b71d 176.I msg_lrpid
fea681da 177ID of the process that performed the last
63f6a20a 178.BR msgrcv (2)
fea681da
MK
179system call.
180.TP
bb38b71d 181.I msg_stime
fea681da 182Time of the last
63f6a20a 183.BR msgsnd (2)
fea681da
MK
184system call.
185.TP
bb38b71d 186.I msg_rtime
fea681da 187Time of the last
1bdcbc01 188.BR msgrcv (2)
fea681da
MK
189system call.
190.TP
bb38b71d 191.I msg_ctime
fea681da
MK
192Time of the last
193system call that changed a member of the
bb38b71d 194.I msqid_ds
fea681da 195structure.
c634028a 196.SS Semaphore sets
fea681da
MK
197A semaphore set is uniquely identified by a positive integer
198.RI "(its " semid )
199and has an associated data structure of type
8478ee02 200.IR "struct semid_ds" ,
fea681da
MK
201defined in
202.IR <sys/sem.h> ,
203containing the following members:
088a639b 204.in +4n
bb38b71d
MK
205.nf
206
207struct 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
218structure that specifies the access permissions on the semaphore
219set.
220.TP
bb38b71d 221.I sem_otime
fea681da 222Time of last
63f6a20a 223.BR semop (2)
fea681da
MK
224system call.
225.TP
bb38b71d 226.I sem_ctime
fea681da 227Time of last
63f6a20a 228.BR semctl (2)
fea681da
MK
229system call that changed a member of the above structure or of one
230semaphore belonging to the set.
231.TP
bb38b71d 232.I sem_nsems
fea681da 233Number of semaphores in the set.
2fda57bd 234Each semaphore of the set is referenced by a nonnegative integer
fea681da
MK
235ranging from
236.B 0
237to
bb38b71d 238.IR sem_nsems\-1 .
fea681da
MK
239.PP
240A semaphore is a data structure of type
8478ee02 241.I "struct sem"
fea681da 242containing the following members:
088a639b 243.in +4n
bb38b71d 244.nf
44b41c64 245
bb38b71d
MK
246struct 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 256Semaphore value: a nonnegative integer.
fea681da 257.TP
bb38b71d 258.I sempid
9b4a382a
MK
259PID of the last process that modified the value of
260this 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
272A shared memory segment is uniquely identified by a positive integer
273.RI "(its " shmid )
274and has an associated data structure of type
8478ee02 275.IR "struct shmid_ds" ,
fea681da
MK
276defined in
277.IR <sys/shm.h> ,
278containing the following members:
088a639b 279.in +4n
bb38b71d
MK
280.nf
281
282struct 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
297structure that specifies the access permissions on the shared memory
298segment.
299.TP
bb38b71d 300.I shm_segsz
fea681da
MK
301Size in bytes of the shared memory segment.
302.TP
bb38b71d 303.I shm_cpid
fea681da
MK
304ID of the process that created the shared memory segment.
305.TP
bb38b71d 306.I shm_lpid
fea681da 307ID of the last process that executed a
63f6a20a 308.BR shmat (2)
fea681da 309or
63f6a20a 310.BR shmdt (2)
fea681da
MK
311system call.
312.TP
bb38b71d 313.I shm_nattch
fea681da
MK
314Number of current alive attaches for this shared memory segment.
315.TP
bb38b71d 316.I shm_atime
fea681da 317Time of the last
63f6a20a 318.BR shmat (2)
fea681da
MK
319system call.
320.TP
bb38b71d 321.I shm_dtime
fea681da 322Time of the last
63f6a20a 323.BR shmdt (2)
fea681da
MK
324system call.
325.TP
bb38b71d 326.I shm_ctime
fea681da 327Time of the last
63f6a20a 328.BR shmctl (2)
fea681da 329system call that changed
bb38b71d 330.IR shmid_ds .
eb25716f
MK
331.SS IPC namespaces
332For a discussion of the interaction of System V IPC objects and
333IPC 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)