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