DETACH (Detach Task) Macro

The macro terminates execution of a task.

A subtask is normally terminated by issuing a DETACH macro in the main task, attaching subtask, or in the subtask itself.

The macro sets byte 2, bit 0 of the ECB to 1 (if specified in the ATTACH macro) to indicate task termination. All tasks waiting on this ECB are taken out of the wait state.

If the subtask issues a DETACH macro without an operand, only the subtask issuing the DETACH macro is terminated. Any subtasks attached by the terminating subtask are not affected by the termination.

If the main task issues the DETACH macro without specifying an operand, it is canceled, that is, all processing in the partition is terminated abnormally. However, the partition might recover, dependent on the AB exit specification.

Format

Read syntax diagramSkip visual syntax diagramnameDETACHSAVE=savearea(1)

Requirements for the caller

AMODE:
24 or 31
RMODE:
24 or ANY
ASC Mode:
Primary

Parameters

SAVE=savearea | (1)
A subtask can also terminate a subtask by issuing the DETACH macro with the SAVE operand. If the main task issues the DETACH macro with the SAVE operand, it can terminate any subtask in the partition. The SAVE operand provides the address of the save area specified in the ATTACH macro for the subtask to be terminated. The save area must be allocated below the 16 MB line.
If the task identified by SAVE cannot be detached by the owning task, the request is ignored. When the address specified by SAVE does not point to the save area of an active task, the result is unpredictable.
Note: If the subtask being terminated uses VSAM files, ensure that these files are closed before you issue this macro.