End a job: controlled

Ending a job in a controlled manner allows programs that are running in the job to perform their end-of-job cleanup. A delay time can be specified to allow the job to end in a controlled manner. If the delay time ends before the job ends, the job is ended immediately.

Any application that needs to perform end-of-job cleanup should detect when the job is ending in a controlled manner. There are three ways an application can detect this:
Synchronously retrieve End Status
At certain points, an application can synchronously check the End Status of the job in which it is running. You can retrieve the job's end status by issuing the Retrieve Job Attributes (RTVJOBA) CL command. Additionally, you can use one of several APIs that retrieve the job's end status. You can find more information about these APIs in the experience report, Work management job attributes
Synchronously check major and minor return codes after an I/O operation
For both display I/O and ICF communications I/O, a major return code of 02, or a major return code of 03 with a minor return code of 09 indicates the job is ending in a controlled manner.
Handle the asynchronous signal SIGTERM
Some applications use a signal handling program to improve the cleanup of the application when the job is ended. The system generates the asynchronous signal SIGTERM for the job being ended, when the job is ending controlled and all of the following conditions are met:
  • The job is enabled for signals
  • The job is a signal handling program that is established for the SIGTERM signal
  • The job is currently running in the problem phase
If any of the above conditions are not met, the SIGTERM signal is not generated for the job being ended.

When a job being ended in a controlled manner has a signal handling procedure for the asynchronous signal SIGTERM, the SIGTERM signal is generated for that job. When the signal handling procedure for the SIGTERM signal is given control, the procedure can take the appropriate actions to allow the application to be ended in a controlled manner.

Related tasks
Stop a subsystem
Related information
Jobs system values: Maximum time for immediate end