shmdt
Purpose
Detaches a shared memory segment.
Syntax
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int shmdt (shmaddr)
char *shmaddr;
Description
The shmdt system call detaches, from the calling proc-
ess's data segment, the shared memory segment located at
the address specified by the shmaddr parameter.
Mapped file segments are automatically detached when no
longer in use. However, you can use the shmdt system
call to explicitly release the segment register used to
map a file. Shared memory segments must be explicitly
detached with shmdt.
Return Value
Upon successful completion, a value of 0 is returned. If
shmdt fails, a value of -1 is returned and errno is set
to indicate the error.
Diagnostics
The shmdt system call fails and the shared memory segment
is not detached if the following is true:
EINVAL The shmaddr parameter is not the data segment
start address of a shared memory segment.
ETXTBSY The shmdt system call attempted to detach a
segment attached to a shared library.
Related Information
In this book: "exec: execl, execv, execle, execve,
execlp, execvp," "exit, _exit," "fclear," "fork,"
"fsync," "shmat," "shmctl," and "shmget."