Posted to tcl by mpcjanssen at Wed Jul 31 12:57:05 GMT 2019view raw
- proc test {args} {puts $args ; return "initialize watch finalize read write"}
- proc nexec {cmd in out stderr} {
- lassign [chan pipe] in1 out1
- lassign [chan pipe] in2 out2
- lassign [chan pipe] in3 out3
- puts [exec {*}$cmd >@ $out2 2>@ $out3 <@ $in1 &]
- fileevent $in2 readable [list chan copy $in2 $out]
- fileevent $in3 readable [list chan copy $in3 $stderr]
- fileevent $out1 writable [list chan copy $in $out1]
- }
- proc test {args} {
- puts $args
- set rest [lassign $args mode chan]
- switch -exact $mode {
- read {puts $chan "Test" ; close $chan}
- initialize {return "initialize watch finalize read write"}
- finalize {}
- }
- }
- set c [chan create "read write" test]
- nexec {sh -c "echo test"} $c $c $c
- vwait forever