XSH_CHAP02_07(3) Library Functions Manual XSH_CHAP02_07(3)

xsh_chap02_07System Interfaces Chapter 2

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
msgctl() msgget() msgrcv() msgsnd() semctl() semget() semop() shmat() shmctl() shmdt() shmget()

Another interprocess communication facility is provided by functions in the Realtime Option Group; see xsh_chap02_08(3).

Each individual shared memory segment, message queue, and semaphore set shall be identified by a unique positive integer, called, respectively, a shared memory identifier, , a semaphore identifier, , and a message queue identifier, . The identifiers shall be returned by calls to shmget(3), semget(3), and msgget(3), 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 (“POSIX.1”), <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 (“POSIX.1”), <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 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 , , or , 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 , , or , 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 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 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 field in xxx_perm.mode is set.

Otherwise, the permission shall be denied. footer end

January 1, 2004 posix.fail