Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

shmat(2) [debian 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

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 <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
Man Page

7 More Discussions You Might Find Interesting

1. Programming

shmat problem

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)
Discussion started by: yong
3 Replies

2. AIX

sharemem-f-shmat

Hi, I got this error from AIX 4.3.3/db2 7: * %SHAREMEM-F-SHMAT Error getting PUTPARM shared memory address , shmid=23029 * * 3630, errno=13 Anybody who know how to fix this? Thanks in advance, itik (1 Reply)
Discussion started by: itik
1 Replies

3. UNIX for Advanced & Expert Users

Problem shmat in HP-UX. EINVAL Error

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)
Discussion started by: dairby
7 Replies

4. Programming

Problem shmat in HP-UX Titanium ia64. EINVAL Error

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)
Discussion started by: dairby
3 Replies

5. UNIX for Advanced & Expert Users

AIX: Finding processes attached to shared memory

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)
Discussion started by: DreamWarrior
7 Replies

6. SuSE

shmat failed due to Cannot allocate memory

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)
Discussion started by: ManoharanMani
5 Replies

7. Shell Programming and Scripting

how to write on separate lines?

Hello friends, I have a file "a.txt" its contents ----------------- pid 4075 (caiopr) shmat(1929379932, 0x0000000000000000, 0) = 0x00000000ff030000 (errno 0) pid 4075 (caiopr) shmdt(0x00000000ff030000) = 144 (errno 0) pid 4075 (caiopr) shmctl(1929379932, IPC_RMID) pid 4205 (cau9cli.exe)... (2 Replies)
Discussion started by: Sunusernewbie
2 Replies