package require rechan proc RechanProc {base_channel cmd chan args} { switch -exact -- $cmd { seek { return 0 } read { return "" } write { return 0 } close { close $base_channel return } } } proc Test {} { # The following channels don't cause a problem. #set f [open NUL w] #set f [socket -server Accept 0] #set f [socket www.google.co.uk 80] # This will crash in TclFinalizeIOSubsystem set f [open [file join [info nameofexecutable] boot.tcl] r] return [rechan [list RchanProc $f] 7] } if {!$tcl_interactive} { set c [Test] puts "opened $c" exit }