COHERENT manpages

This page displays the COHERENT manpage for shmctl() [Manipulate shared memory].

List of available manpages
Index


shmctl() -- General Function (libc)

Manipulate shared memory
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
shmctl(shmid, command, buf)
int shmid, command; struct shmid_ds *buf;

shmctl() controls the  COHERENT system's shared-memory facility.  Note that
shared memory consists  of the segment of memory being  shared, plus a copy
of structure  shmid_ds, which is defined  in header file <sys/shm.h>.
This structure  describes the shared-memory segment  and identifies who can
manipulate it, and how.

command names the operation that you want shmctl() to perform, as follows:

IPC_RMID  Remove  the system  identifier shmid  and destroy  its associated
          shared memory segment and shmid_ds structure.  Only the superuser
          root or  the user  whose effective user  ID matches the  value of
          field uid can invoke this command.

IPC_SET   Copy  fields shm_perm.uid,  shm_perm.gid, and  shm_perm.mode (low
          nine bits only) from the ipc_perm associated with buf into shmid.
          Only  the superuser  root or  the user  who created  this shared-
          memory segment can invoke this command.

IPC_STAT  Copy every element of the shmid_ds associated with shmid into the
          one pointed to by buf.

SHM_LOCK  Lock the shared-memory segment shmid, to keep it from being paged
          out of memory.  Only  the superuser root can invoke this command.
          Because COHERENT  does not  support paging, this  command present
          does nothing.

SHM_UNLOCK
          Unlock the shared-memory segment  shmid, to permit it to be paged
          out of memory.  Only  the superuser root can invoke this command.
          Because COHERENT  does not  support paging, this  command present
          does nothing.

shmctl() fails if any of the following is true:

-> shmid is  not a valid shared-memory identifier.   shmget() sets errno to
   EINVAL.

-> command is not a valid command (EINVAL).

-> command  equals IPC_STAT  but  the owner  of the  calling process  lacks
   permission (EACCES).

-> command equals IPC_RMID or IPC_SET  but the owner of the calling process
   lacks permission (EPERM).

-> buf points to an illegal address (EFAULT).

shmctl() returns zero  if all went well; otherwise, it  returns -1 and sets
errno to an appropriate value.

Example

For an example of this function, see the Lexicon entry for shmget().

Files

/usr/include/sys/ipc.h
/usr/include/sys/shm.h

See Also

libc,
shmat(),
shmdt(),
shmget()

Notes

For  information on  other methods of  interprocess communication,  see the
Lexicon entries for semctl() and msgctl().