a non-blocking [chan pipe] channel blocks when internal buffers fill up
variable total 0
proc write chan {
variable total
variable done
set data [info cmdcount][string repeat abcdefghijklmnopqrstuvwxyz 100]
set len [string length $data]
puts [list writing $len characters]
puts $chan $data
if {[incr total $len] > 1048576} {
close $chan
set done 1
}
}
lassign [chan pipe] pr pw
chan configure $pw -blocking 0
chan event $pw writable [list write $pw]
vwait done
puts done
The documentation for [chan write] states, "A channel is considered to be writable if at least one byte of data can be written to the underlying file or device without blocking, or if an error condition is present on the underlying file or device."
Therefore, this is the expected behaviour.