shmat() - attach shared memory segment
#include <sys/shm.h>
void *shmat(int shmid, const void *shmaddr, int shmflg);
The shmat(2) function attaches the shared memory segment identified by shmid to the address space of the calling process. Shmid is the value returned from shmget(2).) If shmaddr is NULL, the segment is attached at the first available address. Otherwise, the parameters shmaddr and shmflag determine the location of the added segment.
The data structure for shared memory segments and the control flags (such as SHM_RND) are defined in <shm.h>.
To specify the address, make shmaddr non-NULL and:
shmaddr - ((ptrdiff_t)shmaddr%SHMLBA))
where % is the C language modulus (remainder) operator.Permissions on the shared memory segment are determined by the value of shmflag:
The header file <sys/shm.h> includes <sys/ipc.h>.
On success, shmat(2) increments the value of shm_nattach in the data structure and returns the segment's start address.
On failure, shmat(2) returns -1 and sets errno to indicate the error.
The shmat(2) function can fail for the following reasons:
See shmctl(2).
shmctl(2)
shmdt(2),
shmget(2)
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@systemmanager.forsenergy.ru to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.