up | Inhaltsverzeichniss | Kommentar

Manual page for SHMOP(2)

shmop, shmat, shmdt - shared memory operations

SYNOPSIS

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>

char *shmat(shmid, shmaddr, shmflg)
int shmid;
char *shmaddr;
int shmflg;

int shmdt(shmaddr)
char *shmaddr;

DESCRIPTION

shmat() maps the shared memory segment associated with the shared memory identifier specified by shmid into the data segment of the calling process. Upon successful completion, the address of the mapped segment is returned.

The shared memory segment is mapped at the address specified by one of the following criteria:

The segment is mapped for reading if (shmflg & SHM_RDONLY) is ``true'' [READ], otherwise it is mapped for reading and writing [READ/WRITE] (see shmctl.2

shmdt() unmaps from the calling process's address space the shared memory segment that is mapped at the address specified by shmaddr. The shared memory segment must have been mapped with a prior shmat() function call. The segment and contents are retained until explicitly removed by means of the IPC_RMID function (see shmctl.2

RETURN VALUES

shmat() returns the data segment start address of the mapped shared memory segment. On failure, it returns -1 and sets errno to indicate the error.

shmdt() returns:

0
on success.
-1
on failure and sets errno to indicate the error.

ERRORS

shmat() will fail and not map the shared memory segment if one or more of the following are true:
EACCES
Operation permission is denied to the calling process (see intro.2
EINVAL
shmid is not a valid shared memory identifier.

shmaddr is not equal to zero, and the value of (shmaddr - (shmaddr modulus SHMLBA)) is an illegal address.

shmaddr is not equal to zero, (shmflg & SHM_RND) is ``false'', and the value of shmaddr is an illegal address.

EMFILE
The number of shared memory segments mapped to the calling process would exceed the system-imposed limit.
ENOMEM
The available data space is not large enough to accommodate the shared memory segment.

shmdt() will fail and not unmap the shared memory segment if:

EINVAL
shmaddr is not the data segment start address of a shared memory segment.

SEE ALSO

ipcrm.1 ipcs.1 intro.2 execve.2v exit.2v fork.2v shmctl.2 shmget.2


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97