1SVIPC(7)                   Linux Programmer's Manual                  SVIPC(7)
2
3
4

NAME

6       svipc - System V interprocess communication mechanisms
7

SYNOPSIS

9       #include <sys/msg.h>
10       #include <sys/sem.h>
11       #include <sys/shm.h>
12

DESCRIPTION

14       This  manual  page  refers  to the Linux implementation of the System V
15       interprocess communication (IPC) mechanisms: message queues,  semaphore
16       sets,  and shared memory segments.  In the following, the word resource
17       means an instantiation of one among such mechanisms.
18
19   Resource access permissions
20       For each resource, the system uses a common structure  of  type  struct
21       ipc_perm to store information needed in determining permissions to per‐
22       form an IPC operation.  The ipc_perm structure includes  the  following
23       members:
24
25           struct ipc_perm {
26               uid_t          cuid;   /* creator user ID */
27               gid_t          cgid;   /* creator group ID */
28               uid_t          uid;    /* owner user ID */
29               gid_t          gid;    /* owner group ID */
30               unsigned short mode;   /* r/w permissions */
31           };
32
33       The  mode  member  of  the ipc_perm structure defines, with its lower 9
34       bits, the access permissions to the resource for a process executing an
35       IPC system call.  The permissions are interpreted as follows:
36
37           0400    Read by user.
38           0200    Write by user.
39           0040    Read by group.
40           0020    Write by group.
41           0004    Read by others.
42           0002    Write by others.
43
44       Bits  0100, 0010, and 0001 (the execute bits) are unused by the system.
45       Furthermore, "write" effectively means "alter" for a semaphore set.
46
47       The same system header file also defines the  following  symbolic  con‐
48       stants:
49
50       IPC_CREAT     Create entry if key doesn't exist.
51
52       IPC_EXCL      Fail if key exists.
53
54       IPC_NOWAIT    Error if request must wait.
55
56       IPC_PRIVATE   Private key.
57
58       IPC_RMID      Remove resource.
59
60       IPC_SET       Set resource options.
61
62       IPC_STAT      Get resource options.
63
64       Note  that  IPC_PRIVATE  is  a key_t type, while all the other symbolic
65       constants are flag fields and can be OR'ed into an int type variable.
66
67   Message queues
68       A message queue is uniquely  identified  by  a  positive  integer  (its
69       msqid)  and  has  an associated data structure of type struct msqid_ds,
70       defined in <sys/msg.h>, containing the following members:
71
72           struct msqid_ds {
73               struct ipc_perm msg_perm;
74               msgqnum_t       msg_qnum;    /* no of messages on queue */
75               msglen_t        msg_qbytes;  /* bytes max on a queue */
76               pid_t           msg_lspid;   /* PID of last msgsnd(2) call */
77               pid_t           msg_lrpid;   /* PID of last msgrcv(2) call */
78               time_t          msg_stime;   /* last msgsnd(2) time */
79               time_t          msg_rtime;   /* last msgrcv(2) time */
80               time_t          msg_ctime;   /* last change time */
81           };
82
83       msg_perm   ipc_perm structure that specifies the access permissions  on
84                  the message queue.
85
86       msg_qnum   Number of messages currently on the message queue.
87
88       msg_qbytes Maximum  number of bytes of message text allowed on the mes‐
89                  sage queue.
90
91       msg_lspid  ID of the process that performed the last  msgsnd(2)  system
92                  call.
93
94       msg_lrpid  ID  of  the process that performed the last msgrcv(2) system
95                  call.
96
97       msg_stime  Time of the last msgsnd(2) system call.
98
99       msg_rtime  Time of the last msgrcv(2) system call.
100
101       msg_ctime  Time of the last system call that changed a  member  of  the
102                  msqid_ds structure.
103
104   Semaphore sets
105       A  semaphore  set  is  uniquely  identified  by a positive integer (its
106       semid) and has an associated data structure of  type  struct  semid_ds,
107       defined in <sys/sem.h>, containing the following members:
108
109                  struct semid_ds {
110                      struct ipc_perm sem_perm;
111                      time_t          sem_otime;   /* last operation time */
112                      time_t          sem_ctime;   /* last change time */
113                      unsigned long   sem_nsems;   /* count of sems in set */
114                  };
115
116       sem_perm   ipc_perm  structure that specifies the access permissions on
117                  the semaphore set.
118
119       sem_otime  Time of last semop(2) system call.
120
121       sem_ctime  Time of last semctl(2) system call that changed a member  of
122                  the  above  structure  or  of one semaphore belonging to the
123                  set.
124
125       sem_nsems  Number of semaphores in the set.  Each semaphore of the  set
126                  is  referenced  by  a  nonnegative integer ranging from 0 to
127                  sem_nsems-1.
128
129       A semaphore is a data structure of type struct sem containing the  fol‐
130       lowing members:
131
132           struct sem {
133               int semval;  /* semaphore value */
134               int sempid;  /* PID of process that last modified */
135           };
136
137       semval     Semaphore value: a nonnegative integer.
138
139       sempid     PID of the last process that modified the value of this sem‐
140                  aphore.
141
142   Shared memory segments
143       A shared memory segment is uniquely identified by  a  positive  integer
144       (its  shmid)  and  has  an  associated  data  structure  of type struct
145       shmid_ds, defined in <sys/shm.h>, containing the following members:
146
147           struct shmid_ds {
148               struct ipc_perm shm_perm;
149               size_t          shm_segsz;   /* size of segment */
150               pid_t           shm_cpid;    /* PID of creator */
151               pid_t           shm_lpid;    /* PID, last operation */
152               shmatt_t        shm_nattch;  /* no. of current attaches */
153               time_t          shm_atime;   /* time of last attach */
154               time_t          shm_dtime;   /* time of last detach */
155               time_t          shm_ctime;   /* time of last change */
156           };
157
158       shm_perm   ipc_perm structure that specifies the access permissions  on
159                  the shared memory segment.
160
161       shm_segsz  Size in bytes of the shared memory segment.
162
163       shm_cpid   ID of the process that created the shared memory segment.
164
165       shm_lpid   ID  of the last process that executed a shmat(2) or shmdt(2)
166                  system call.
167
168       shm_nattch Number of current alive attaches for this shared memory seg‐
169                  ment.
170
171       shm_atime  Time of the last shmat(2) system call.
172
173       shm_dtime  Time of the last shmdt(2) system call.
174
175       shm_ctime  Time   of  the  last  shmctl(2)  system  call  that  changed
176                  shmid_ds.
177
178   IPC namespaces
179       For a discussion of the interaction of System V  IPC  objects  and  IPC
180       namespaces, see namespaces(7).
181

SEE ALSO

183       ipcmk(1),  ipcrm(1),  ipcs(1),  lsipc(1), ipc(2), msgctl(2), msgget(2),
184       msgrcv(2), msgsnd(2), semctl(2), semget(2),  semop(2),  shmat(2),  shm‐
185       ctl(2), shmdt(2), shmget(2), ftok(3), namespaces(7)
186

COLOPHON

188       This  page  is  part of release 4.15 of the Linux man-pages project.  A
189       description of the project, information about reporting bugs,  and  the
190       latest     version     of     this    page,    can    be    found    at
191       https://www.kernel.org/doc/man-pages/.
192
193
194
195Linux                             2016-03-15                          SVIPC(7)
Impressum