Closing files

You can use fclose(), freopen(), or close() to close a file. z/OS® XL C/C++ automatically closes files on normal program termination, and attempts to do so under abnormal program termination or abend. See z/OS XL C/C++ Runtime Library Reference for more information on these library functions. For z/OS UNIX low-level I/O, you can use the close() function. When you use any exec() or fork() function, files defined as "marked to be closed" are closed before control is returned.