Posted to tcl by mr_calvin at Wed Sep 30 06:48:08 GMT 2020view raw
- set pipe [open "|ls"]
- chan configure $pipe -blocking 0
- set handler [list pr {
- puts RUN=[incr [namespace current]::RUN]
- if {[eof $pr]} {
- chan close $pr
- set [namespace current]::done 1
- } else {
- set result [read $pr]
- puts RESULT='$result'
- }
- } [namespace current]]
- chan event $pipe readable [list apply $handler $pipe]
- vwait [namespace current]::done