SHMAT(2) BSD System Calls Manual SHMAT(2)NAME
shmat, shmdt -- attach or detach shared memory
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
void *
shmat(int shmid, const void *addr, int flag);
int
shmdt(const void *addr);
DESCRIPTION
The shmat() system call attaches the shared memory segment identified by shmid to the calling process's address space. The address where the
segment is attached is determined as follows:
o If addr is 0, the segment is attached at an address selected by the kernel.
o If addr is nonzero and SHM_RND is not specified in flag, the segment is attached the specified address.
o If addr is specified and SHM_RND is specified, addr is rounded down to the nearest multiple of SHMLBA.
The shmdt() system call detaches the shared memory segment at the address specified by addr from the calling process's address space.
RETURN VALUES
Upon success, shmat() returns the address where the segment is attached; otherwise, -1 is returned and errno is set to indicate the error.
The shmdt() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate
the error.
ERRORS
The shmat() system call will fail if:
[EINVAL] No shared memory segment was found corresponding to shmid.
[EINVAL] The addr argument was not an acceptable address.
The shmdt() system call will fail if:
[EINVAL] The addr argument does not point to a shared memory segment.
SEE ALSO shmctl(2), shmget(2)BSD August 2, 1995 BSD
Check Out this Related Man Page
SHMAT(2) BSD System Calls Manual SHMAT(2)NAME
shmat, shmdt -- attach or detach shared memory
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <machine/param.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
void *
shmat(int shmid, const void *addr, int flag);
int
shmdt(const void *addr);
DESCRIPTION
The shmat() system call attaches the shared memory segment identified by shmid to the calling process's address space. The address where the
segment is attached is determined as follows:
o If addr is 0, the segment is attached at an address selected by the kernel.
o If addr is nonzero and SHM_RND is not specified in flag, the segment is attached the specified address.
o If addr is specified and SHM_RND is specified, addr is rounded down to the nearest multiple of SHMLBA.
The shmdt() system call detaches the shared memory segment at the address specified by addr from the calling process's address space.
RETURN VALUES
Upon success, shmat() returns the address where the segment is attached; otherwise, -1 is returned and errno is set to indicate the error.
The shmdt() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate
the error.
ERRORS
The shmat() system call will fail if:
[EINVAL] No shared memory segment was found corresponding to shmid.
[EINVAL] The addr argument was not an acceptable address.
The shmdt() system call will fail if:
[EINVAL] The addr argument does not point to a shared memory segment.
SEE ALSO shmctl(2), shmget(2)BSD August 2, 1995 BSD
The first shmat in my program cannot fetch the start address of the shared memory.
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int main(int argc,char *argv) {
int pid;
key_t mykey;
int shmid;
long *shm;
long *shm2;
... (3 Replies)
I have a process that need two active connections to the same zone of shared memory. But when i do the second call to shmat it give me error 22 (EINVAL). Only works ok the second call to shmat if i disconnect the first connection (shmdt)
In Sun,AIX and Digital, i donīt have this problem.
... (7 Replies)
I have a process that needs two active connections to the same zone of shared memory simultaneously.
The firs conection works ok, but when i do the second call to shmat it give me error 22 (EINVAL). Only works ok the second call to shmat if i disconnect the first connection (shmdt)
Steps:... (3 Replies)
Is there some way to tell what processes are attached to a shared memory segment? We have a system on which I perform "icps -ma" and there are several segments pending deletion having numerous processes attached to them and I can't tell what processes they are. Neither the creator's pid nor last... (7 Replies)
Hi,
My program was running for a whole night. after 12 hours i got an error message "Cannot allocate memory" during the shmat commmand. So can you please let me know what could be the reason? is there any solution?
thanks in advance.
Regards,
Mano (5 Replies)