Index: openacs-4/packages/acs-templating/tcl/util-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/util-procs.tcl,v diff -u -r1.31 -r1.32 --- openacs-4/packages/acs-templating/tcl/util-procs.tcl 19 Dec 2017 16:22:11 -0000 1.31 +++ openacs-4/packages/acs-templating/tcl/util-procs.tcl 22 Dec 2017 13:17:47 -0000 1.32 @@ -443,14 +443,22 @@ @return A string with the contents of the file. } { + # + # Use ad_try to make sure, that the file descriptor is finally + # closed. + # + ad_try { + set fd [open $path] + template::util::set_file_encoding $fd + set text [read $fd] + } on error {errMsg opts} { + dict incr opts -level + ns_log error "template::util::read_file on fd $fd: $errMsg,\n$::errorInfo" + return -options [dict replace $opts -inside $opts] $errMsg + } finally { + close $fd + } - set fd [open $path] - - template::util::set_file_encoding $fd - - set text [read $fd] - close $fd - return $text }