Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
shmdt(2)
Edit
PageHistory
Diff
Info
LikePages
SHMOP !!!SHMOP NAME SYNOPSIS DESCRIPTION SYSTEM CALLS RETURN VALUE ERRORS NOTES CONFORMING TO SEE ALSO ---- !!NAME shmop - shared memory operations !!SYNOPSIS __# include ____void *shmat ( int__ ''shmid''__, const void *__''shmaddr''__, int__ ''shmflg'' __)__ __int shmdt ( const void *__''shmaddr''__)__ !!DESCRIPTION The function __shmat__ attaches the shared memory segment identified by __shmid__ to the data segment of the calling process. The attaching address is specified by ''shmaddr'' with one of the following criteria: If ''shmaddr'' is __0__, the system tries to find an unmapped region in the range 1 - 1.5G starting from the upper value and coming down from there. If ''shmaddr'' isn't __0__ and __SHM_RND__ is asserted in ''shmflg'', the attach occurs at address equal to the rounding down of ''shmaddr'' to a multiple of __SHMLBA__. Otherwise ''shmaddr'' must be a page aligned address at which the attach occurs. If __SHM_RDONLY__ is asserted in ''shmflg'', the segment is attached for reading and the process must have read access permissions to the segment. Otherwise the segment is attached for read and write and the process must have read and write access permissions to the segment. There is no notion of write-only shared memory segment. The __brk__ value of the calling process is not altered by the attach. The segment will automatically detached at process exit. The same segment may be attached as a read and as a read-write one, and more than once, in the process's address space. On a successful __shmat__ call the system updates the members of the structure __shmid_ds__ associated to the shared memory segment as follows: __shm_atime__ is set to the current time. __shm_lpid__ is set to the process-ID of the calling process. __shm_nattch__ is incremented by one. Note that the attach succeeds also if the shared memory segment is marked as to be deleted. The function __shmdt__ detaches from the calling process's data segment the shared memory segment located at the address specified by ''shmaddr''. The detaching shared memory segment must be one among the currently attached ones (to the process's address space) with ''shmaddr'' equal to the value returned by the its attaching __shmat__ call. On a successful __shmdt__ call the system updates the members of the structure __shmid_ds__ associated to the shared memory segment as follows: __shm_dtime__ is set to the current time. __shm_lpid__ is set to the process-ID of the calling process. __shm_nattch__ is decremented by one. If it becomes 0 and the segment is marked for deletion, the segment is deleted. The occupied region in the user space of the calling process is unmapped. !!SYSTEM CALLS __fork()__ After a __fork()__ the child inherits the attached shared memory segments. __exec()__ After an __exec()__ all attached shared memory segments are detached (not destroyed). __exit()__ Upon __exit()__ all attached shared memory segments are detached (not destroyed). !!RETURN VALUE On a failure both functions return __-1__ with __errno__ indicating the error, otherwise __shmat__ returns the address of the attached shared memory segment, and __shmdt__ returns __0__. !!ERRORS When __shmat__ fails, at return __errno__ will be set to one among the following values: __EACCES__ The calling process has no access permissions for the requested attach type. __EINVAL__ Invalid ''shmid'' value, unaligned (i.e., not page-aligned and __SHM_RND__ was not specified) or invalid ''shmaddr'' value, or failing attach at __brk__. __ENOMEM__ Could not allocate memory for the descriptor or for the page tables. The function __shmdt__ can fails only if there is no shared memory segment attached at ''shmaddr'', in such a case at return __errno__ will be set to __EINVAL__. !!NOTES On executing a fork(2) system call, the child inherits all the attached shared memory segments. The shared memory segments attached to a process executing an execve(2) system call will not be attached to the resulting process. The following is a system parameter affecting a __shmat__ system call: __SHMLBA__ Segment low boundary address multiple. Must be page aligned. For the current implementation the __SHMBLA__ value is __PAGE_SIZE__. The implementation has no intrinsic limit to the per process maximum number of shared memory segments (__SHMSEG__) !!CONFORMING TO SVr4, SVID. SVr4 documents an additional error condition EMFILE. In SVID-v4 the type of the ''shmaddr'' argument was changed from __char *__ into __const void *__, and the returned type of ''shmat''() from __char *__ into __void *__. (Linux libc4 and libc5 have the __char *__ prototypes; glibc2 has __void *__.) !!SEE ALSO ipc(5), shmctl(2), shmget(2) ----
5 pages link to
shmdt(2)
:
ipc(2)
Man2s
ipc(5)
semctl(2)
shmget(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.