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 Specifies 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 Identifiers
A shared memory identifier remains allocated until it is removed. An allocated shared memory
identifier is not removed when the last process using it terminates. The user must remove allo-
cated shared memory identifiers that are not attached to processes to avoid wasting shared
memory resources.
The status of shared memory identifiers can be checked with the ipcs command. Shared memory
identifiers can be removed using the ipcrm command. The associated shared memory segment
and data structure are removed only after the final 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 identifier is not the Guardian environment segid value or segment identifier.
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 7−51