[Overview][Constants][Types][Procedures and functions] Reference for unit 'ipc' (#rtl)

shmat

Attach a shared memory block.

Declaration

Source position: ipc.pp line 171

function shmat(

  shmid: cint;

  shmaddr: pointer;

  shmflg: cint

):pointer;

Description

shmatattaches a shared memory block with identified shmidto the current process. The function returns a pointer to the shared memory block.

If shmaddris Nil, then the system chooses a free unmapped memory region, as high up in memory space as possible.

If shmaddris non-nil, and SHM_RNDis in shmflg, then the returned address is shmaddr, rounded down to SHMLBA. If SHM_RNDis not specified, then shmaddrmust be a page-aligned address.

The parameter shmflgcan be used to control the behaviour of the shmatcall. It consists of a ORed combination of the following constants:

SHM_RND
The suggested address in shmaddris rounded down to SHMLBA.
SHM_RDONLY
the shared memory is attached for read access only. Otherwise the memory is attached for read-write. The process then needs read-write permissions to access the shared memory.

For an example, see shmctl.

Errors

If an error occurs, -1 is returned, and IPCerroris set.

See also

shmget

  

Return the ID of a shared memory block, possibly creating it

shmdt

  

Detach shared memory block.

shmctl

  

Perform control operations on a shared memory block.