close(file); always necessary??

John L. Ries jries at
Tue Jun 15 18:38:35 CEST 2010

On Mon, 14 Jun 2010, Rugxulo wrote:

> Hey,
>   In non-standard Pascal mode, does it matter if I explicitly close
> the file or not? E.g., "close(file);", is that done automatically or
> is it implementation defined? (I'm 99% sure DOS always closes files
> upon exit.) I'm just wondering if that's a fair assumption for Linux,
> etc. (though I kinda doubt it).
I believe most, if not all, modern operating systems automatically close 
all open files when a process terminates, but I've never relied on that. 
It's nearly always better to close files explicitly.  The only exception I 
can think of is if you're working in a language like AWK or SAS which 
opens and closes files automatically (Pascal doesn't fall into that 

John L. Ries              |
Salford Systems           |
Phone: (619)543-8880 x107 |
or     (435)867-8885      |

More information about the Gpc mailing list