

            close (2) --- close out an open file                     03/25/82


            _C_a_l_l_i_n_g _I_n_f_o_r_m_a_t_i_o_n

                 integer function close (fd)
                 file_des fd

                 Library:  vswtlb (standard Subsystem library)


            _F_u_n_c_t_i_o_n

                 'Close'  closes  the  file  associated  with  the given file
                 descriptor  (the  value  returned  by  a  call  to   'open',
                 'create',  or  'mktemp')  and releases its buffer areas.  If
                 the file was open for writing, any data  still  buffered  is
                 written  to  the  file.   After  a  file is closed, its file
                 descriptor  becomes  available  for  future  use.    'Close'
                 returns  OK  if  the  attempt  to  close was successful, ERR
                 otherwise.

                 If an attempt is made  to  close  a  standard  port  (STDIN,
                 STDOUT, etc.)  'close' will return OK, but it will _n_o_t close
                 the file associated with the port.


            _I_m_p_l_e_m_e_n_t_a_t_i_o_n

                 'Close'  first checks to see if the given file descriptor is
                 a standard port descriptor.  If so, the attempt to close  is
                 ignored.   If  the file descriptor is illegal or corresponds
                 to an already closed file, ERR  is  returned.   'Flush$'  is
                 then  called  to  force any pending writes on the file to be
                 performed.  The Primos routine SRCH$$ is used to close  disk
                 files;  other  file types are closed simply by updating Sub-
                 system status areas.


            _C_a_l_l_s

                 flush, Primos srch$$


            _B_u_g_s

                 Some consider the behavior on standard  ports  unreasonable,
                 but it definitely seems useful.


            _S_e_e _A_l_s_o

                 open (2), create (2), mktemp (2), flush$ (6)








            close (2)                     - 1 -                     close (2)


