ATTACH and ATTACHX description

The ATTACH macro causes the system to create a new task and indicates the entry point in the program to be given control when the new task becomes active. The entry point name that is specified must be a member name or an alias in a directory of a partitioned data set, or must have been specified in an IDENTIFY macro. If the system cannot locate the specified entry point, it abnormally terminates the new subtask.

The descriptions of ATTACH and ATTACHX are:
  • The standard form of the ATTACH macro, which includes general information about the ATTACH and ATTACHX macros, with some specific information about the ATTACH macro. The syntax of the ATTACH macro is presented, and all ATTACH parameters are explained.
  • The standard form of the ATTACHX macro, which includes information specific to the ATTACHX macro and to callers in AR mode.
  • The list form of the ATTACH and ATTACHX macros.
  • The execute form of the ATTACH and ATTACHX macros.

The new task is a subtask of the originating task. The originating task is the active task when the ATTACH macro is issued. The limit and dispatching priorities of the new task are the same as those of the originating task (unless modified in the ATTACH macro).

The load module containing the program to be given control is brought into virtual storage unless a usable copy is available in virtual storage. The issuing program can provide: an event control block, in which termination of the subtask is posted; an exit routine to be given control, when the subtask is terminated; and a parameter list the address of which is passed in GPR 1 to the subtask. The subtask is automatically removed from the system upon completion of its execution, unless the ECB or ETXR parameters are coded.

ATTACH and ATTACHX are also described in z/OS MVS Programming: Assembler Services Reference ABE-HSP, with the exception of the following parameters, which are restricted to use by authorized programs: SM, SVAREA, KEY, DISP, TID, NSHSPV, NSHSPL, JSTCB, and RSAPF.

Environment

The requirements for the caller of ATTACH or ATTACHX are:

Environmental factor Requirement
Minimum authorization: Problem state, and any PSW key. To use the SM, SVAREA, KEY, DISP, TID, NSHSPV, NSHSPL, JSTCB, or RSAPF parameter, the caller must either run in supervisor state or with PSW key 0-7. When the caller specifies JSTCB=YES and the program comes from an APF-authorized library or the link pack area and is link-edited with the APF-authorization attribute, the task runs with APF authorization.
Dispatchable unit mode: Task
Cross memory mode: PASN=HASN=SASN
AMODE: If you use the STAI parameter, 24-bit; otherwise, 24- or 31- or 64-bit
Note: AMODE 64 is valid only for the ATTACHX macro.
ASC mode: If you use the STAI parameter, primary; otherwise, primary or access register (AR)
Interrupt status: Enabled for I/O and external interrupts
Locks: No locks held
Control parameters: For both primary ASC mode callers and AR ASC mode callers, control parameters must be in the primary address space.

Programming requirements

If your program is in AR mode, issue SYSSTATE ASCENV=AR so the system can generate code that is appropriate for AR mode. If you issue SYSSTATE ASCENV=AR and then issue ATTACH, the system substitutes the ATTACHX macro and issues a message telling you that it made the substitution.

Restrictions

  • If the caller is running in 31-bit addressing mode, all input parameters can have addresses greater than 16 megabytes, except for the address of the DCB.
  • The ECB must be in storage addressable by both the caller of ATTACH and the system.
  • Only job step tasks can issue ATTACH with JSTCB=YES. A task cannot issue a series of ATTACH macros that would cause its subtasks to be a mix of job step and nonjob step tasks.
  • The caller cannot have an EUT FRR established.
  • The parameter list specified for an ESTAI exit must be addressable using a 31-bit address.

Input register information

Before issuing the ATTACH or ATTACHX macro, if you want to pass a parameter list to the new task without coding the PARAM or MF=E parameter, the caller must ensure that the following GPR contains the specified information:
Register
Contents
1
Address of the parameter list

Output register information

When control returns to the caller, the GPRs contain:
Register
Contents
0
Used as a work register by the system
1
If GPR 15 contains a return code other than X'00', zero; otherwise, the address of the task control block for the subtask
2-13
Unchanged
14
Used as a work register by the system
15
Return code
When control returns to the caller, the ARs contain:
Register
Contents
0
Used as a work register by the system
1
Zero (the ALET of the task control block address)
2-13
Unchanged
14-15
Used as work registers by the system

Some callers depend on register contents remaining the same before and after issuing a service. If the system changes the contents of registers on which the caller depends, the caller must save them before issuing the service, and restore them after system returns.

Performance implications

None.

Syntax

The standard form of the ATTACH macro is written as follows:

Syntax Description
   
   name name: Symbol. Begin name in column 1.
   
One or more blanks must precede ATTACH.
   
ATTACH  
   
One or more blanks must follow ATTACH.
   
EP=entry name entry name: Symbol.
EPLOC=entry name addr entry name addr: A-type address, or register (2) - (12).
DE=list entry addr list entry addr: A-type address, or register (2) - (12).
   
   ,DCB=dcb addr dcb addr: A-type address, or register (2) - (12).
   
   ,LPMOD=limit prior nmbr limit prior nmbr: Symbol, decimal digit, or register (2) - (12).
   
   ,DPMOD=disp prior nmbr disp prior nmbr: Symbol, decimal digit, or register (2) - (12).
   
   ,PARAM=(addr) addr: A-type address
   ,PARAM=(addr),VL=1 Note: addr is one or more addresses, separated by commas. For example, PARAM=(addr,addr,addr)
   
   ,ECB=ecb addr ecb addr: A-type address, or register (2) - (12).
   
   ,ETXR=exit rtn addr exit rtn addr: A-type address, or register (2) - (12).
   
   ,GSPV=subpool nmbr subpool nmbr: Symbol, decimal digit, or register (2) - (12).
   ,GSPL=subpool list addr subpool list addr: A-type address, or register (2) - (12).
   
   ,SHSPV=subpool nmbr subpool nmbr: Symbol, decimal digit, or register (2) - (12).
   ,SHSPL=subpool list addr subpool list addr: A-type address, or register (2) - (12).
   
   ,SZERO=YES Default: SZERO=YES
   ,SZERO=NO  
   
   ,TASKLIB=dcb addr dcb addr: A-type address, or register (2) - (12).
   
   ,STAI=(exit addr) exit addr: A-type address, or register (2) - (12).
   ,STAI=(exit addr,parm addr) parm addr: A-type address, or register (2) - (12).
   ,ESTAI=(exit addr) Note: AR mode callers and 31-bit callers must not use STAI.
   ,ESTAI=(exit addr,parm addr)  
   
   ,PURGE=QUIESCE Note: PURGE may be specified only if STAI or ESTAI is specified.
   ,PURGE=NONE Default for STAI: PURGE=QUIESCE
   ,PURGE=HALT Default for ESTAI: PURGE=NONE
   
   ,ASYNCH=NO Default for STAI: ASYNCH=NO
   ,ASYNCH=YES Default for ESTAI: ASYNCH=YES
  Note: ASYNCH may be coded only if STAI or ESTAI is specified.
   
   ,TERM=NO Note: TERM may be specified only if ESTAI is specified.
   ,TERM=YES Default: TERM=NO
   
   ,JSTCB=NO Default: JSTCB=NO
   ,JSTCB=YES  
   
   ,SM=PROB Default: SM=PROB
   ,SM=SUPV  
   
   ,SVAREA=YES Default: SVAREA=YES
   ,SVAREA=NO  
   
   ,KEY=PROP Default: KEY=PROP
   ,KEY=ZERO  
   
   ,DISP=YES Default: DISP=YES
   ,DISP=NO  
   ,DISP=RESET,TCB=tcb addr tcb addr: RX-type address or address in register (2) - (12).
   
   ,TID=task id task id: Decimal digits 0-255, or register (2) - (12).
  Default: TID=0
 
Note: IBM® recommends that you specify a value less than 200.
   
   ,NSHSPV=subpool nmbr subpool nmbr: Symbol, decimal digit, or register (2) - (12).
   ,NSHSPL=subpool list addr subpool list addr: A-type address, or register (2) - (12).
   
   ,RSAPF=NO Default: RSAPF=NO
   ,RSAPF=YES  
   
   ,ALCOPY=YES Default: ALCOPY=NO
   ,ALCOPY=NO  
   
   ,RELATED=value value: Any valid macro keyword specification.
   

Parameters

The parameters are explained as follows:

EP=entry name
EPLOC=entry name addr
DE=list entry addr
Specifies the entry name, the address of the entry name, or the address of the name field of a 62-byte entry name list. The entry name is constructed using the BLDL macro. When EPLOC is coded, entry name addr points to an eight-byte field. When the name is less than eight characters, left-justify the name and pad with blanks on the right to make up the eight characters.
Note:
  1. ATTACH processing can attach a load module in 24-bit or 31-bit addressing mode physically resident above or below 16 megabytes virtual. The AMODE and RMODE, load module attributes located in the directory entry for the load module, provide this information. The RMODE indicates the place of the module; the AMODE indicates the addressing mode of the module. When the AMODE of the entry point is ANY, it is attached with the same addressing mode as the caller.
  2. When you use the DE parameter with the ATTACH macro, DE specifies the address of a list created by a BLDL macro. You must issue the BLDL and the ATTACH from the same task; otherwise, the system abnormally terminates the program with a completion code of X'106'. Do not issue an ATTACH or a DETACH between issuances of the BLDL and ATTACH.
  3. See z/OS DFSMS Macro Instructions for Data Sets and z/OS DFSMS Using Data Sets for a description of the BLDL macro.
The contents of the GPRs on entry to the subtask are:
Register
Contents
0
Does not contain any information for use by the routine.
1
Address of the user parameter list if specified on either the PARAM or MF=E parameters; otherwise, contains whatever GPR 1 contained at the time the ATTACH macro was issued.
2 - 12
Do not contain any information for use by the routine.
13
Address of a 144-byte save area if SVAREA=YES was specified; Otherwise, zero.
14
Return address. Bit 0 is 0 if the subtask routine gets control in 24-bit addressing mode; bit 0 is 1 if the subtask routine gets control in 31-bit addressing mode.
15
When the subtask routine is to run in 24-bit or 31-bit addressing mode, the entry point address of the subtask routine.
When the subtask routine is to run in 64-bit addressing mode, it is expected to use relative branching and register 15 contains a value that can be used to determine the addressing mode of the issuer of the ATTACH or ATTACHX macro as follows:
  • Issuer AMODE 24: X'FFFFF000'
  • Issuer AMODE 31: X'FFFFF002'
  • Issuer AMODE 64: X'FFFFF004'
Note: Start of changeFor assistance in converting a program to use relative branching, refer to the IEABRC and IEABRCX macros.End of change
The contents of the ARs on entry to the subtask are:
Register
Contents
0
Does not contain any information for use by the routine.
1
Zero if you specified a user parameter list on either the PARAM or MF=E parameters; otherwise, contains whatever AR 1 contained at the time the ATTACH macro was issued.
2-12
Do not contain any information for use by the routine.
13-15
Zeroes
,DCB=dcb addr
Specifies the address of the data control block for the partitioned data set containing the entry name.
Note: The DCB must be opened before the ATTACH macro is executed. The DCB must reside in storage below 16 megabytes.
,LPMOD=limit prior nmbr
Specifies the number (0 to 255) to be subtracted from the current limit priority of the originating task. The resulting number is the limit priority of the subtask, with a higher number representing a higher limit priority.

If you omit this parameter, the current limit priority of the originating task is assigned as the limit priority of the subtask.

,DPMOD=disp prior nmbr
Specifies the signed number (-255 to +255) to be algebraically added to the current dispatching priority of the originating task. The resulting number is assigned as the dispatching priority of the subtask, with a higher number representing a higher dispatching priority. If, however, the resulting number is higher than the limit priority of the subtask, the limit priority is assigned as the dispatching priority.

If a register is designated, a negative number must be in two's complement form in the register. If you omit this parameter, the dispatching priority assigned is the smaller of either the subtask's limit priority or the originating task's dispatching priority.

,PARAM=(addr)
,PARAM=(addr),VL=1
Specifies an address or addresses to be passed to the attached program. ATTACH expands each address inline to a fullword on a fullword boundary, in the order designated, building a parameter list. When the program receives control, register 1 contains the address of the first word of the parameter list.

Specify VL=1 only if the called program can be passed a variable number of parameters. VL=1 causes the high-order bit of the last address to be set to 1; the bit can be checked to find the end of the list.

,ECB=ecb addr
Specifies the address of an event control block for the subtask. The system uses this to indicate the termination of the subtask. This enables the issuer of the attach to wait on it, using the WAIT macro, and enables the system to post it on behalf of the terminating task. The return code, (when the task terminates normally), or the completion code, (when the task terminates abnormally), is placed in the event control block. When this parameter is coded, a DETACH macro must be issued to remove the subtask from virtual storage after the subtask terminates. The system assumes that the ECB is in the home address space.
,ETXR=exit rtn addr
Specifies the address of the end-of-task exit routine. It is given control after the subtask normally or abnormally terminates. The exit routine is given control when the originating task becomes active after the subtask terminates. It must be in virtual storage. When this parameter is coded, a DETACH macro must be issued to remove the subtask from the system after the subtask terminates.

The exit routine runs asynchronously under the originating task. The routine receives control in the addressing mode of the issuer of the ATTACH macro. The system abnormally ends a task with completion code X'72A' if the task attempts to create two subtasks with the same exit routine in different addressing modes. Upon entry, the routine has an empty dispatchable unit access list (DU-AL). To establish addressability to a data space created by the originating task and shared with the terminating subtask, the routine can issue the ALESERV macro with the ADD parameter, and specify the STOKEN of the data space.

The exit routine receives control with the following environment:

Environmental factor Requirement
Authorization: Problem state, PSW key is the same as TCB key of the issuer of the ATTACH macro.
Dispatchable unit mode: Task
Cross memory mode: PASN=HASN=SASN
AMODE: 24-bit when the issuer of the ATTACH macro is AMODE 24; Otherwise, 31-bit.
ASC mode: Primary
Interrupt status: Enabled for I/O and external interrupts
Locks: No locks held
Control parameters: Not applicable.
When the exit routine is given control, the contents of the GPRs are:
Register
Contents
0
Does not contain any information for use by the routine.
1
Address of the task control block for terminated task
2-12
Do not contain any information for use by the routine.
13
Address of a 72-byte save area provided by the system
14
Return address
15
Address of the exit routine
When the exit routine receives control, the contents of ARs are:
Register
Contents
0
Does not contain any information for use by the routine.
1
Zero
2-12
Do not contain any information for use by the routine.
13-15
Zeroes
The exit routine is responsible for saving and restoring the registers.
,GSPV=subpool nmbr
,GSPL=subpool list addr
Specifies a virtual storage subpool number, or address of a list of virtual storage subpool numbers, each less than 128. Ownership of each of the specified subpools is assigned to the subtask. Subpool zero is an exception. It can be specified but it cannot be transferred. When a task transfers ownership of a subpool, it can no longer obtain or release the associated virtual storage areas. When GSPL is specified, the first byte of the list contains the number of remaining bytes in the list. Each of the following bytes contains a virtual storage subpool number.
,SHSPV=subpool nmbr
,SHSPL=subpool list addr
Specifies a virtual storage subpool number or the address of a list of virtual storage subpool numbers, each less than 128. Programs of the originating task and the subtask can use the associated virtual storage areas. When SHSPL is specified, the first byte of the list contains the number of remaining bytes in the list. Each of the following bytes contains a virtual storage subpool number.
,SZERO=YES
,SZERO=NO
Specifies whether subpool 0 is to be shared (YES) or not to be shared (NO) with the subtask.
,TASKLIB=dcb addr
Specifies the address of the DCB for the library to be used as the attached subtask's library. Otherwise, the subtask library is propagated from the originating task. (Note: The DCB must be opened before the ATTACH macro is executed.) SYS1.LINKLIB is the last library searched. If the DCB address specifies SYS1.LINKLIB, the search begins with SYS1.LINKLIB, goes through other libraries, and ends with SYS1.LINKLIB. The system abnormally terminates the attached subtask with a completion code of X'806' if the requested module is not in the subtask library and is not in the other libraries searched.

See “Location of the Load Module” in z/OS MVS Programming: Assembler Services Guide for additional information on using the TASKLIB parameter.

Note: DCB must reside in 24-bit addressable storage.
,STAI=(exit addr)
,STAI=(exit addr,parm addr)
,ESTAI=(exit addr)
,ESTAI=(exit addr,parm addr)
Specifies whether a STAI or ESTAI recovery routine is to be defined for the attached task; any STAI or ESTAI recovery routines defined for the attached task are automatically propagated to its subtasks.

The exit addr specifies the address of the STAI or ESTAI recovery routine that is to receive control if the subtask encounters an error; the recovery routine must be in virtual storage at the time of the error. The parm addr is the address of a parameter list which may be used by the STAI or ESTAI recovery routine. The address must be 24-bit for STAI and 31-bit for ESTAI.

ATTACHX processing passes control to an ESTAI recovery routine in the addressing mode of the issuer of the ATTACHX macro. A STAI exit routine can run only in 24-bit addressing mode. If a caller in the wrong addressing mode or AR mode specifies the STAI parameter on the ATTACH macro, the caller ends abnormally with a completion code of X'52A'.

,PURGE=QUIESCE
,PURGE=NONE
,PURGE=HALT
Specifies the action to be taken with regard to I/O operations when the subtask encounters an error. NONE indicates that no action is specified. HALT indicates halting of I/O operations. QUIESCE indicates quiescing of I/O operations.
,ASYNCH=NO
,ASYNCH=YES
Specifies whether asynchronous exits are to be allowed when a subtask encounters an error.
ASYNCH=YES must be coded if:
  • Any supervisor services that require asynchronous interruptions to complete their normal processing are going to be requested by the recovery routine.
  • PURGE=QUIESCE is specified for any access method that requires asynchronous interruptions to complete normal input/output processing.
  • PURGE=NONE is specified and the CHECK macro is issued in the recovery routine for any access method that requires asynchronous interruptions to complete normal input/output processing.
Note: If ASYNCH=YES is specified and the error was an error in asynchronous exit handling, recursion will develop when an asynchronous exit handling was the cause of the failure.
,TERM=NO
,TERM=YES
Specifies whether the recovery routine associated with the ESTAI request is scheduled in these situations:
  • System-initiated logoff
  • Job step timer expiration
  • Wait time limit for job step exceeded
  • DETACH macro without the STAE=YES parameter issued from a higher-level task (possibly by the system if the higher-level task encountered an error)
  • Operator cancel
  • Error on a higher-level task
  • Error in the job step task when a nonjob step task issued the ABEND macro with the STEP parameter.
  • z/OS UNIX is canceled and the user's task is in a wait in the z/OS UNIX kernel.
,JSTCB=NO
,JSTCB=YES
Specifies whether the attached task is to be a job step task. YES specifies that the attached task is to be a job step task.
NO specifies that the attached task is to be a nonjob step task and that the job step task of the issuer of ATTACH will be propagated to the newly attached task.
Note:
  1. JSTCB=YES causes a new job pack area to be established for the attached task. Modules within the job pack area of the task issuing the ATTACH are not available to the newly attached task. See information about program management in z/OS MVS Programming: Authorized Assembler Services Guide for details.
  2. The use of JSTCB=YES affects the ownership of those virtual storage subpools that are owned by job step tasks. See information about virtual storage management in z/OS MVS Programming: Authorized Assembler Services Guide for details.
  3. Do not specify JSTCB=YES unless you know that the design of your application requires the special attributes of a job step task.
,SM=PROB
,SM=SUPV
PROB specifies that the attached task is to run in problem state. SUPV specifies that the attached subtask is to run in supervisor state.
,SVAREA=YES
,SVAREA=NO
Specifies whether a save area is needed for the attached task. YES specifies that the ATTACH routine obtains a 144-byte save area. When the attaching and attached task share subpool zero, the save area is obtained there. Otherwise, it is obtained from a new 4KB block. NO specifies that no save area is needed.
,KEY=PROP
,KEY=ZERO
ZERO specifies that the protection key of the newly created task should be zero. PROP specifies that the protection key of the newly created task should be propagated from the task using ATTACH.
,DISP=YES
,DISP=NO
,DISP=RESET,TCB=tcb addr
YES specifies that the attached subtask is dispatchable. NO specifies that the subtask is nondispatchable; the system places the address of the TCB for the task in GPR 1, but ATTACH processing for the task does not complete.

When you specify DISP=NO, you must issue ATTACH again with the DISP=RESET,TCB=tcb addr parameter so that ATTACH processing completes for the subtask. When you issue ATTACH with DISP=RESET,TCB=tcb addr, you cannot specify any other parameters on the ATTACH macro. ATTACH DISP=RESET,TCB=tcb addr resets to dispatchable the subtask specified by tcb addr and all subtasks of the attaching program that were attached using the DISP=NO parameter.

,TID=task id
Specifies the task identifier to be placed in the TCB field of the attached subtask. IBM recommends that you specify a value less than 200 for task id.
,NSHSPV=subpool nmbr
,NSHSPL=subpool list addr
Specifies the virtual storage subpool number 236 or 237, or the address of a list of virtual storage subpool numbers 236 and 237. The subpools specified are not shared with the subtask.

When NSHSPL is specified, the first byte of the list contains the number of bytes remaining in the list. Each of the subsequent bytes contains a virtual storage subpool number.

,RSAPF=YES
,RSAPF=NO
Specifies that the attached subtask comes from an unauthorized library. When it comes from an APF-authorized library or the link pack area and is link-edited with the APF-authorized attribute, the step begins execution with APF authorization.
RSAPF=YES when these conditions are met:
  • The caller is running in supervisor state, system key (0-7), or both
  • The caller is running non-APF authorized
  • The subtask is attached in the problem program state and with a nonsystem key.

Specify RSAPF=NO when the APF authorization of the step is to remain unchanged.

,ALCOPY=NO
,ALCOPY=YES
Specifies the EAX value for the subtask and determines the contents of its access list. ALCOPY=NO gives the subtask an EAX of zero and a null access list. ALCOPY=YES gives the subtask:
  • The same EAX as the caller
  • A copy of the caller's DU-AL. For details about how the system copies a DU-AL, see the topic on access lists in z/OS MVS Extended Addressability Guide.

The default is ALCOPY=NO.

,RELATED=(value)
Specifies information used to self-document macros by “relating” functions or services to corresponding functions or services. The format and contents of the information specified are at the discretion of the user. They can be any valid coding values.

ABEND codes

The caller of ATTACH or ATTACHX might receive one of the following hexadecimal ABEND codes:

ABEND Code Associated Reason Code
12A 0,4
22A 0
42A None
52A 0,4,8
72A 0,4,8,C,10,14
82A None
92A 0,4,8,C,10,14,18
Note: ABEND code 92A results from an error not directly caused by the caller.

See z/OS MVS System Codes for explanations and responses for these codes.

Return codes

When control is returned, register 15 contains one of the return codes in the following table.

Table 1. Return codes for the ATTACH or ATTACHX macros
Hexadecimal Return Code Meaning and Action
00 Meaning: Successful completion.

Action: None.

04 Meaning: Program error. ATTACH was issued in a STAE exit. Processing not completed.

Action: Change your program so that the ATTACH is not issued in a STAE exit.

08 Meaning: Environmental error. Insufficient storage available for control block for STAI/ESTAI request. Processing not completed.

Action: Retry the request.

0C Meaning: Program error. An incorrect exit routine address or incorrect parameter list address was specified with STAI parameter. Processing not completed.

Action: Ensure that the exit routine and parameter list addresses are correct.

14 Meaning: Program error. An authorized task that specified JSTCB=YES is not a job step task. Processing not completed.

Action: Either remove the JSTCB=YES option from this ATTACH macro or specify JSTCB=YES on the ATTACH macro for the current task.

18 Meaning: Program error. An attempt to create a new subtask would cause the current task to have a mix of job step and nonjob step subtasks. Processing not completed.

Action: Change your program so that the ATTACH macros that it issues all specify the same value for JSTCB=.

20 Meaning: Program error, due to one of the following reasons:
  • The current task was not subspace active and the ATTACHX macro specified ADDRENV=SUBSP.
  • The current task is a subspace task that is not subspace active and issued either ATTACH, or ATTACHX with ADDRENV=SAME specified or defaulted.
Action:
  • If the current task was not subspace active and the ATTACHX macro specified ADDRENV=SUBSP, update your program so that it issues ATTACHX with ADDRENV=SUBSP only if it is subspace active.
  • If the current task is a subspace task that is not subspace active and ADDRENV=SAME was specified or defaulted, update your program so that it issues ATTACH, or ATTACHX with ADDRENV=SAME specified or defaulted, only if it is not a subspace task or is a subspace task that is not subspace active.
24 Meaning: Program error. ADDRENV=SAME was specified or defaulted and the issuer was a subspace task that is subspace active, but the task was processing with a different active subspace than that which was in effect when it was attached.

Action: Update your program if it is a subspace task and subspace active so that it issues ATTACH or ATTACHX with ADDRENV=SAME only if the task was processing with the same active subspace that was in effect when it was attached.

Note: It is possible for the originating task to obtain return code 00, and still not have the subtask successfully created (for example, if the entry name could not be found). In such cases, the new subtask is abnormally terminated.

Example 1

Attach program SYSPROGM, runs with protection key 0 and in supervisor mode. Subpool 0 is not to be shared, and the subtask is not to have a save area.
 ATTACH EP=SYSPROGM,KEY=ZERO,SM=SUPV,SZERO=NO,SVAREA=NO

Example 2

Cause the program named in the list to be attached. Establish RTN as an end of task exit routine.
  ATTACH  DE=LISTNAME,ETXR=RTN

Example 3

Cause PROGRAM1 to be attached, share subpool 5, supply WORD1 so that the originating task can know when the subtask is complete, and establish EXIT1 as an ESTAI exit.
  ATTACH  EP=PROGRAM1,SHSPV=5,ECB=WORD1,ESTAI=(EXIT1)

Example 4

Cause PROGRAM1 to be attached, and share subpool zero. The subtask is to receive control:
  • With the same extended authorization index EAX as the caller.
  • With a copy of the caller's DU-AL.
          ATTACH EP=PROGRAM1,SZERO=YES,ALCOPY=YES