NAME
svipc - System V interprocess communication mechanisms SYNOPSIS
#include
#include
#include
DESCRIPTION This manual page refers to the Linux implementation of the System V interprocess communication (IPC) mechanisms: message queues, semaphore sets, and shared memory segments. In the following, the word resource means an instantiation of one among such mechanisms. Resource access permissions For each resource, the system uses a common structure of type struct ipcperm to store information needed in determining permissions to per‐ form an IPC operation. The ipcperm structure includes the following members: struct ipcperm { uidt cuid; /* creator user ID */ gidt cgid; /* creator group ID */ uidt uid; /* owner user ID */ gidt gid; /* owner group ID */ unsigned short mode; /* r/w permissions */ }; The mode member of the ipcperm structure defines, with its lower 9 bits, the access permissions to the resource for a process executing an IPC system call. The permissions are interpreted as follows: 0400 Read by user. 0200 Write by user. 0040 Read by group. 0020 Write by group. 0004 Read by others. 0002 Write by others. Bits 0100, 0010, and 0001 (the execute bits) are unused by the system. Furthermore, "write" effectively means "alter" for a semaphore set. The same system header file also defines the following symbolic con‐ stants: IPCCREAT Create entry if key doesn't exist. IPCEXCL Fail if key exists. IPCNOWAIT Error if request must wait. IPCPRIVATE Private key. IPCRMID Remove resource. IPCSET Set resource options. IPCSTAT Get resource options. Note that IPCPRIVATE is a keyt type, while all the other symbolic constants are flag fields and can be OR'ed into an int type variable. Message queues A message queue is uniquely identified by a positive integer (its msqid) and has an associated data structure of type struct msqidds, defined in , containing the following members: struct msqidds { struct ipcperm msgperm; msgqnumt msgqnum; /* no of messages on queue */ msglent msgqbytes; /* bytes max on a queue */ pidt msglspid; /* PID of last msgsnd(2) call */ pidt msglrpid; /* PID of last msgrcv(2) call */ timet msgstime; /* last msgsnd(2) time */ timet msgrtime; /* last msgrcv(2) time */ timet msgctime; /* last change time */ }; msgperm ipcperm structure that specifies the access permissions on the message queue. msgqnum Number of messages currently on the message queue. msgqbytes Maximum number of bytes of message text allowed on the mes‐ sage queue. msglspid ID of the process that performed the last msgsnd(2) system call. msglrpid ID of the process that performed the last msgrcv(2) system call. msgstime Time of the last msgsnd(2) system call. msgrtime Time of the last msgrcv(2) system call. msgctime Time of the last system call that changed a member of the msqidds structure. Semaphore sets A semaphore set is uniquely identified by a positive integer (its semid) and has an associated data structure of type struct semidds, defined in , containing the following members: struct semidds { struct ipcperm semperm; timet semotime; /* last operation time */ timet semctime; /* last change time */ unsigned long semnsems; /* count of sems in set */ }; semperm ipcperm structure that specifies the access permissions on the semaphore set. semotime Time of last semop(2) system call. semctime Time of last semctl(2) system call that changed a member of the above structure or of one semaphore belonging to the set. semnsems Number of semaphores in the set. Each semaphore of the set is referenced by a nonnegative integer ranging from 0 to semnsems-1. A semaphore is a data structure of type struct sem containing the fol‐ lowing members: struct sem { int semval; /* semaphore value */ int sempid; /* PID for last operation */ }; semval Semaphore value: a nonnegative integer. sempid ID of the last process that performed a semaphore operation on this semaphore. Shared memory segments A shared memory segment is uniquely identified by a positive integer (its shmid) and has an associated data structure of type struct shmidds, defined in
, containing the following members: struct shmidds { struct ipcperm shmperm; sizet shmsegsz; /* size of segment */ pidt shmcpid; /* PID of creator */ pidt shmlpid; /* PID, last operation */ shmattt shmnattch; /* no. of current attaches */ timet shmatime; /* time of last attach */ timet shmdtime; /* time of last detach */ timet shmctime; /* time of last change */ }; shmperm ipcperm structure that specifies the access permissions on the shared memory segment. shmsegsz Size in bytes of the shared memory segment. shmcpid ID of the process that created the shared memory segment. shmlpid ID of the last process that executed a shmat(2) or shmdt(2) system call. shmnattch Number of current alive attaches for this shared memory seg‐ ment. shmatime Time of the last shmat(2) system call. shmdtime Time of the last shmdt(2) system call. shmctime Time of the last shmctl(2) system call that changed shmidds. SEE ALSO ipcmk(1), ipcrm(1), ipcs(1), ipc(2), msgctl(2), msgget(2), msgrcv(2), msgsnd(2), semctl(2), semget(2), semop(2), shmat(2), shmctl(2), shmdt(2), shmget(2), ftok(3) COLOPHON This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2013-02-12 SVIPC(7)