z/OS UNIX process start/end exits

Four installation exits are defined to enable applications to monitor z/OS UNIX process activity. Exit routines can be added to each exit point. z/OS UNIX passes control to the exit routine when an exit point is reached, and information about the current process and its creator is then passed to the exit routine. These are the installation exits:
Pre-process initiation exit (BPX_PREPROC_INIT)
Pre-process initiation exit routines receive control immediately before the creation of any new z/OS UNIX process. When a pre-process initiation exit routine receives control, the Process Exit Data Block (PEDB) contains the data about the initiating job.

Upon return from the exit, if the exit's return code is greater than 4, the process initiation request will be rejected. The z/OS UNIX callable service that drove this process initiation request will fail with a return value of -1, a return code of EAGAIN, and a reason code of JrPreProcInitExitReject.

The pre-process initiation exit should have a recovery routine to clean up any resources that it obtained. If the exit does not have a recovery routine, first-failure capture is not possible, and resources that were obtained will not be released. Should an exit abend, the z/OS UNIX callable service that drove this process initiation request will fail with a return value of -1, a return code of EAGAIN, and a reason code of JrPreProcInitExitAbend.

The sole purpose of the pre-process initiation exit point is to provide an application with the ability to fail an attempt to initialize a process. If this is not the intent of your exit routine, you should not use this exit point. Do not use this exit point if, for example, your primary purpose is to monitor the initialization and termination of processes in the system, because it does not receive enough information to identify the process that is to be initialized. When it receives control, the only information the exit has available (from the PEDB) is the unique ID and information about the initiator of the process.

Recommendation: Resources should not be obtained at this exit point, because it is possible that another exit routine could subsequently fail the process initialization attempt, and no further exit points would be driven for this process, including the process termination exit. Resources that relate to the process should be obtained in the post-process initialization exit, where the process is fully initialized, and the termination exit will eventually run upon termination of the process.

Rule: This exit should not use any z/OS UNIX callable service. To do so could cause unexpected results, such as ABEND 138–ENQ deadlock.
Post-process initiation exit (BPX_POSPROC_INIT)
Post-process initiation exit routines receive control immediately after the creation of any new z/OS UNIX process. When a post-process initiation exit routine receives control, the Process Exit Data Block (PEDB) contains the creator and the new process data.

The post-process initiation exit should have a recovery routine to clean up any resources that it obtained. If the exit does not have a recovery routine, first-failure capture is not possible, and resources that were obtained will not be released. Should an exit abend, the z/OS UNIX callable service that drove this process initiation request will fail with a return value of -1, a return code of EAGAIN, and a reason code of JrPosProcInitExitAbend.

Rule: This exit should not use any z/OS UNIX callable service. To do so could cause unexpected results, such as ABEND 138–ENQ deadlock.
Process image initiation exit (BPX_IMAGE_INIT)
Process image initiation exit routines receive control immediately before the initiation of a new z/OS UNIX process image. This occurs when a successful spawn, attach_exec, attach_execmvs, exec or execmvs callable service is done. The process image initiation exit receives control before the new process image file is run. When a process image initiation exit routine receives control, the Process Exit Data Block (PEDB) contains the data of the creator and the new image.

The process image initiation exit should have a recovery routine to clean up any resources it obtained. If the exit does not have a recovery routine, first-failure capture is not possible, and resources that were obtained will not be released. Should an exit abend, the z/OS UNIX callable service that drove this process receives a successful return code, but the image is not created, and an EC6 ABEND with a ImageInitExitABEND reason code is issued.

Rule: This exit should not use any z/OS UNIX callable service. To do so could cause unexpected results, such as ABEND 138–ENQ deadlock.
Pre-process termination exit (BPX_PREPROC_TERM)
Pre-process termination exit routines receive control immediately before the termination of a z/OS UNIX process. These exits may receive control in the address space of the process or in the master address space, if the address space of the process was terminated. In the latter case (ASID=1), z/OS UNIX callable services cannot be used by the exit. When a pre-process termination exit receives control, the Process Exit Data Block (PEDB) contains data about the terminating process.