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 spec