Close considerations for files shared in a job

 

The processing done when a program closes a shared file depends on whether other programs currently share the open data path.

If there are other programs, the main function that is performed is to detach from the file the program that is requesting the close. For database files, the program also releases any record locks that it holds. The program will not be able to use the shared file unless it opens it again. All other programs sharing the file are still attached to the ODP and can perform I/O operations.

If the program closing the file is the last program sharing the file, then the close operation performs all the functions it would if the file had not been opened with the share option. This includes releasing any allocated resources for the file and destroying the open data path.

The function provided by this last close operation is the function that is required for recovering from certain runtime errors. If your application is written to recover from such errors and it uses a shared file, this means that all programs that are attached to the file when the error occurs must close the file. This might require returning to previous programs in the call stack and closing the file in each one of those programs.

 

Parent topic:

Shared files