9.81 shmat

void *shmat(int shmid, const void *shmaddr, int shmflg);

This syscall attaches the shared memory segment identified by shmid to the address space of the calling process.

If shmaddr is NULL, the system chooses a suitable (unused) address at which to attach the segment. If it is not NULL, that address will be used for attaching.

If SHM_RDONLY is specified in shmflg, the segment is attached fo reading and the process must have read permission for the segment. Otherwise the segment is attached for read and write and the process must have read and write permission for the segment. There is no notion of a write-only shared memory segment.

The syscall returns 0 on success or -1 on failure, with the following errno:

EACCES

The caller does not have enough permissions for attaching.

EIDRM

shmid points to a removed identifier.

EINVAL

Invalid shmid or invalid shmaddr.

ENOMEM

Not enough memory.