shmdt Subroutine
Purpose
Detaches a shared memory segment.
Library
Standard C Library (libc.a)
Syntax
#include <sys/shm.h>
const void * SharedMemoryAddress;
Description
The shmdt subroutine detaches from the data segment of the calling process the shared memory segment located at the address specified by the SharedMemoryAddress parameter.
Mapped file segments are automatically detached when the mapped file is closed. However, you can use the shmdt subroutine to explicitly release the segment register used to map a file. Shared memory segments must be explicitly detached with the shmdt subroutine.
If the file was mapped for writing, the shmdt subroutine updates the mtime and ctime time stamps.
The following limits apply to shared memory:
- Maximum shared-memory segment size is 64 GB for 64-bit applications.
- Minimum shared-memory segment size is 1 byte.
- Maximum number of shared memory IDs is 131072.
Parameters
Item | Description |
---|---|
SharedMemoryAddress | Specifies the data segment start address of a shared memory segment. |
Return Values
When successful, the shmdt subroutine returns a value of 0. Otherwise, the shared memory segment at the address specified by the SharedMemoryAddress parameter is not detached, a value of -1 is returned, and the errno global variable is set to indicate the error.
Error Codes
The shmdt subroutine is unsuccessful if the following condition is true:
Item | Description |
---|---|
EINVAL | The value of the SharedMemoryAddress parameter is not the data-segment start address of a shared memory segment. |