Posted to tcl by kostix at Sat Nov 07 17:52:49 GMT 2009view raw
- set active 0
- proc Spawn what {
- variable active
- set fd [open "| $what &"]
- fileevent $fd readable [list ReadLine $fd]
- incr active
- }
- proc ReadLine fd {
- if {[gets $fd line] < 0} {
- incr active -1
- if {$active == 0} {
- set ::done 1
- }
- }
- }
- Spawn my_program
- # repeat N times
- vwait done