z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Closing a file

z/OS UNIX System Services User's Guide
SA23-2279-00

The operating system has a limit on the number of streams to a file that a process can open. The shell closes a stream for you when a shell script ends. However, to conserve on the number of active file streams, you can close regular files when you are finished working with them in a shell script. To close a regular file, use either of the following:
exec n<&-
exec n>&-
where n can be file descriptors 3 through 9.
Similarly, you can close standard output, standard input, and standard error when you do not need them. For example, for an application that does not display anything, you may want to close standard output. Here is the command syntax for those files:
  • exec 0<&- (close standard input)
  • exec 1>&- (close standard output)
  • exec 2>&- (close standard error)

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014