shmdt (BPX1MDT, BPX4MDT) — Detach a shared memory segment

Function

The shmdt service detaches a shared memory segment.

Requirements

Operation Environment
Authorization: Supervisor state or problem state; PSW key 2, 8, or 9
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1MDT): 31-bit
AMODE (BPX4MDT): 64-bit
ASC mode: Primary mode
Interrupt status: Enabled for interrupts
Locks: Unlocked
Control parameters: All parameters must be addressable by the caller and in the primary address space.

Format

CALL BPX1MDT,(Shared_Memory_Address,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4MDT with the same parameters. The Shared_Memory_Address parameter is a doubleword.

Parameters

Shared_Memory_Address
Supplied parameter
Type:
Integer
Length:
Fullword (doubleword)

The name of a fullword (doubleword) field that contains the starting address of a shared memory segment. This is the Return_value from shmat (BPX1MAT,BPX4MAT). The address returned is 31 bits for AMODE 31 callers and 64 bits for AMODE 64 callers.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the shmdt service returns 0 if the request was successful, or -1 if the operation was unsuccessful.

Return_code
Returned parameter
Type:
Integer
Length:
Fullword
The name of a fullword in which the shmdt service stores the return code. The shmdt service returns Return_code only if Return_value is -1. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The shmdt service can return one of the following values in the Return_code parameter:
Return_code Explanation
EINVAL Shared_Memory_Address is not the data segment start address of a shared memory segment attached to the caller's process. The following reason code can accompany the return code: JRBadAddress.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the shmdt service stores the reason code. The shmdt service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. See z/OS UNIX System Services Messages and Codes for the reason codes.

Related services

Usage notes

Characteristics and restrictions

The caller of the shmdt service is restricted by ownership and read and read-write permissions that are defined by shmget and shmctl Ipc_SET.

Examples

For an example using this callable service, see BPX1MDT (shmdt) example.