[XSI] This section describes extensions to support interprocess communication. This functionality is dependent on support of the XSI extension (and the rest of this section is not further marked for this option).
The following message passing, semaphore, and shared memory services form an XSI interprocess communication facility. Certain aspects of their operation are common, and are defined as follows.
IPC Functions |
||
---|---|---|
Another interprocess communication facility is provided by functions in the Realtime Option Group; see Realtime.
Each individual shared memory segment, message queue, and semaphore set shall be identified by a unique positive integer, called, respectively, a shared memory identifier, shmid, a semaphore identifier, semid, and a message queue identifier, msqid. The identifiers shall be returned by calls to shmget(), semget(), and msgget(), respectively.
Associated with each identifier is a data structure which contains data related to the operations which may be or may have been performed; see the Base Definitions volume of IEEE Std 1003.1-2001, <sys/shm.h>, <sys/sem.h>, and <sys/msg.h> for their descriptions.
Each of the data structures contains both ownership information and an ipc_perm structure (see the Base Definitions volume of IEEE Std 1003.1-2001, <sys/ipc.h>) which are used in conjunction to determine whether or not read/write (read/alter for semaphores) permissions should be granted to processes using the IPC facilities. The mode member of the ipc_perm structure acts as a bit field which determines the permissions.
The values of the bits are given below in octal notation.
Bit |
Meaning |
---|---|
0400 |
Read by user. |
0200 |
Write by user. |
0040 |
Read by group. |
0020 |
Write by group. |
0004 |
Read by others. |
0002 |
Write by others. |
The name of the ipc_perm structure is shm_perm, sem_perm, or msg_perm, depending on which service is being used. In each case, read and write/alter permissions shall be granted to a process if one or more of the following are true ( "xxx" is replaced by shm, sem, or msg, as appropriate):
The process has appropriate privileges.
The effective user ID of the process matches xxx_perm.cuid or xxx_perm.uid in the data structure associated with the IPC identifier, and the appropriate bit of the user field in xxx_perm.mode is set.
The effective user ID of the process does not match xxx_perm.cuid or xxx_perm.uid but the effective group ID of the process matches xxx_perm.cgid or xxx_perm.gid in the data structure associated with the IPC identifier, and the appropriate bit of the group field in xxx_perm.mode is set.
The effective user ID of the process does not match xxx_perm.cuid or xxx_perm.uid and the effective group ID of the process does not match xxx_perm.cgid or xxx_perm.gid in the data structure associated with the IPC identifier, but the appropriate bit of the other field in xxx_perm.mode is set.
Otherwise, the permission shall be denied.