Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (s and S) shmdt(2)
NAME
shmdt - Detaches a shared memory segment
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
H-series OSS processes: /G/system/zdllnnn/zosskdll
SYNOPSIS
#include <sys/shm.h>
int shmdt(
const void *shmaddr);
PARAMETERS
shmaddr Species the starting virtual address for the shared memory segment that is to be
detached. This is the address returned by a previous shmat() function call.
DESCRIPTION
The shmdt() function detaches the shared memory segment at the indicated address from the
address space of the calling process.
Address Range
An application that is using the shared memory functions shmat() and shmdt() to manage a
range of virtual addresses should use only these functions to manipulate the range.
The valid range of addresses for the shmaddr parameter can change from one release to the next.
Programs should not contain hard-coded addresses.
Cleaning Up Shared Memory Identiers
A shared memory identier remains allocated until it is removed. An allocated shared memory
identier is not removed when the last process using it terminates. The user must remove allo-
cated shared memory identiers that are not attached to processes to avoid wasting shared
memory resources.
The status of shared memory identiers can be checked with the ipcs command. Shared memory
identiers can be removed using the ipcrm command. The associated shared memory segment
and data structure are removed only after the nal detach operation.
Use From the Guardian Environment
If called from a Guardian process, the function call fails and errno is set to to the value of [ENO-
TOSS].
NOTES
The shared memory identier is not the Guardian environment segid value or segment identier.
Programs should not be written to depend upon the maximum number of attached shared seg-
ments. This limit is subject to change.
The maximum number of attached segments decreases when the size of any attached segment
exceeds SHMLBA.
Programs should not be written to depend upon the region size. The region size is subject to
change.
Refer to the SEGMENT_ALLOCATE_ procedure description in the Guardian Procedure Calls
Reference Manual for more information about segment limits.
527186-003 Hewlett-Packard Company 751