***COMMAND*** close - Close an open channel ***USAGE*** '''close''' channelId ***CONTEXT*** TCL core command ***DESCRIPTION*** Closes the channel given by ''channelId''. ''ChannelId'' must be an identifier for an open channel such as a Tcl standard channel (stdin, stdout, or stderr), the return value from an invocation of [open] or [socket], or the result of a channel creation command provided by a Tcl extension. ***MAN PAGE*** http://www.tcl.tk/man/tcl8.5/TclCmd/close.htm ***SEE ALSO*** [file], [open], [socket], [eof], [channel], [exec], [stderr] ***EXAMPLES*** set fh [open output.txt r] set data [read $fh] close $fh ---- [LV] What are the ramifications if you don't close a file in Tcl? Any? I assume a memory leak in long running ''[daemon]'' type apps... ---- [glennj]: When working with pipes (i.e. [[set pipe [[open "| some command"]]]]), and the pipe is blocking (i.e. [[fconfigure $pipe -blocking yes]] which is the default), then [[close $pipe]] throws an error if the command exited with non-zero status or if the command sent any output to stderr. example: set command {sh -c {echo "to stdout"; echo >&2 "to stderr"; exit 42}} set pipe [open "| $command"] set standard_output [read -nonewline $pipe] set exit_status 0 if {[catch {close $pipe} standard_error] != 0} { global errorCode if {"CHILDSTATUS" == [lindex $errorCode 0]} { set exit_status [lindex $errorCode 2] } } puts "exit status is $exit_status" puts "captured standard output: {$standard_output}" puts "captured standard error: {$standard_error}" Output is: exit status is 42 captured standard output: {to stdout} captured standard error: {to stderr} ---- [AMG]: TIP #332 "Half-Close for Bidirectional Channels" [http://tip.tcl.tk/332] adds an optional argument to specify which direction of the channel to close, like the shutdown(2) system call [http://linux.die.net/man/2/shutdown]. '''close''' ''channel'' ?'''read'''|'''write'''? ---- !!!!!! [Tcl syntax help] - [Arts and crafts of Tcl-Tk programming] %| [Category Command] | [Category Channel] |% !!!!!!