1.4 IPC system calls
This section provides an overview of the IPC system calls. See the
specific sections on each type of resource for details.
Each type of mechanism provides a "get", "ctl" and one or more "op"
system calls that allow the user to create or procure the resource
(get), define its behaviour or destroy it (ctl) and manipulate the
1.4.1 The "get" system calls
The `get' call typically takes a KEY and returns a numeric ID that is
used for further access. The ID is an index into the resource table. A
sequence number is maintained and incremented when a resource is
destroyed so that access using an obsolete ID is likely to fail.
The user also specifies the permissions and other behaviour
charecteristics for the current access. The flags are or-ed with the
permissions when invoking system calls as in:
msgflg = IPC_CREAT | IPC_EXCL | 0666;
id = msgget (key, msgflg);
* `key' : IPC_PRIVATE => new instance of resource is initialized.
* `flags' :
IPC_CREAT : resource created for KEY if it does not exist.
IPC_CREAT | IPC_EXCL : fail if resource exists for KEY.
* returns : an identifier used for all further access to the
Note that IPC_PRIVATE is not a flag but a special `key' that ensures
(when the call is successful) that a new resource is created.
Use of IPC_PRIVATE does not make the resource inaccessible to other
users. For this you must set the access permissions appropriately.
There is currently no way for a process to ensure exclusive access
to a resource. IPC_CREAT | IPC_EXCL only ensures (on success) that a new
resource was initialized. It does not imply exclusive access.
See Also : msgget, semget, shmget.
1.4.2 The "ctl" system calls
Provides or alters the information stored in the structure that
describes the resource indexed by ID.
struct msqid_ds buf;
err = msgctl (id, IPC_STAT, &buf);
printf ("creator uid = %d\n", buf.msg_perm.cuid);
Commands supported by all `ctl' calls:
* IPC_STAT : read info on resource specified by id into user
allocated buffer. The user must have read access to the resource.
* IPC_SET : write info from buffer into resource data structure. The
user must be owner creator or super-user.
* IPC_RMID : remove resource. The user must be the owner, creator or
The IPC_RMID command results in immediate removal of a message queue
or semaphore array. Shared memory segments however, are only destroyed
upon the last detach after IPC_RMID is executed.
The `semctl' call provides a number of command options that allow
the user to determine or set the values of the semaphores in an array.
See Also: msgctl, semctl, shmctl.
1.4.3 The "op" system calls
Used to send or receive messages, read or alter semaphore values,
attach or detach shared memory segments. The IPC_NOWAIT flag will
cause the operation to fail with error EAGAIN if the process has to
wait on the call.
`flags' : IPC_NOWAIT => return with error if a wait is required.
See Also: msgsnd, msgrcv, semop, shmat,
automatically generated by