Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.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 and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZOSSKDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zosskdll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yosskdll
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
On servers running J06.12 or later J-series RVUs or H06.23 or later H-series RVUs, Guardian
processes can use the shmdt() function to detach from shared memory segments.
If called from a Guardian process on servers running J06.11 or earlier J-series RVUs, H06.22 or
earlier H-series RVUs, or G-series RVUs, the function call fails and errno is set to the value of
[ENOTOSS].
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.
Refer to the SEGMENT_ALLOCATE_ procedure in the Guardian Procedure Calls Reference
Manual for more information about segment limits.
527186-023 Hewlett-Packard Company 7−83