SYNOPSIS
#include <sys/shm.h>
void *shmat(int shmid, const void *shmaddr, int shmflg);
DESCRIPTION
The
- If shmaddr is a NULL pointer, the segment is attached at the first available address as selected by the system.
- If shmaddr is not a NULL pointer and (shmflg & SHM_RND) is non-zero, the segment is attached at the address given by (shmaddr - (shmaddr % SHMLBA)).
- If shmaddr is not a NULL pointer and (shmflg & SHM_RND) is 0, the segment is attached at the address given by shmaddr.
The segment is attached for reading if (shmflg & SHM_RDONLY) is non-zero and the calling process has read permission, otherwise if (shmflg & SHM_RDONLY) is zero and the calling process has read and write permission, the segment is attached for reading and writing.
Upon successful completion,
You must explicitly remove shared memory segments after the last reference to them has been removed.
PARAMETERS
- shmid
-
Is a unique positive integer created by a
shmget() system call and associated with a segment of shared memory. - shmaddr
-
Points to the desired address of the shared memory segment.
- shmflg
-
Specifies a set of flags that indicate the specific shared memory conditions and options to implement.
RETURN VALUES
If successful,
- EACCES
-
Operation permission is denied to the calling process.
- EINVAL
-
shmaddr is not equal to zero, and the value of (shmaddr - (shmaddr % SHMLBA)) is an illegal address.
shmaddr is not equal to zero, (shmflg & SHM_RND) is 0, and the value of shmaddr is an illegal address.
shmid is not a valid shared memory identifier.
- EMFILE
-
The number of shared memory segments attached to the calling process exceeds the system-imposed limit.
- ENOMEM
-
The available data space is not large enough to accommodate the shared memory segment.
CONFORMANCE
UNIX 98, with exceptions.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
Windows requires that attached shared memory regions be aligned on 64K
boundaries. If you attempt to use
On Windows 9x,
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
execl() ,execle() ,execlp() ,execlpe() ,execv() ,execve() ,execvp() ,execvpe() ,exit() ,fork() ,shmctl() ,shmdt() ,shmget()
PTC MKS Toolkit 10.4 Documentation Build 39.