#include <sys/shm.h> int shmdt(const void *shmaddr);
The shmdt() function detaches the shared memory segment
specified by shmaddr from the calling job. The shmaddr
is the value returned by the shmat function.
The system maintains status information about a shared memory segment which can be retrieved with the shmctl() function. When a shared memory segment is successfully detached, the system sets the members of the shmid_ds structure as follows:
Authorization Required for shmdt()
Object Referred to | Authority Required | errno |
---|---|---|
Shared memory segment to be detached | None | None |
0 | shmdt() was successful. |
-1 | shmdt() was not successful. The errno variable is set to indicate the error. |
If shmdt() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
A damaged object was encountered.
The shared memory segment has been damaged by a previous shared memory operation.
The address used for an argument is not correct.
In attempting to use an argument in a call, the system detected an address that is not valid.
While attempting to access a parameter passed to this function, the system detected an address that is not valid.
The value specified for the argument is not correct.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
The value of shmaddr is not the start address of a shared memory segment.
Function not implemented.
An attempt was made to use a function that is not available in this implementation for any object or any arguments.
The function is not implemented.
Unknown system state.
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.
None.
See Code disclaimer information for information pertaining to code examples.
For an example of using this function, see Using Semaphores and Shared Memory in Examples: APIs.
Top | UNIX-Type APIs | APIs by category |