Re: Handling mutiple channels using fileevent - or not
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Handling mutiple channels using fileevent - or not

From: al-s <stosh259@hotmail.com>
Date: Thu Mar 02 2006 - 21:55:21 CET

Fantastic!
This works great - Thanks. I added to what you posted as a further
improvement.

You had:
proc Run1 {command log} {
    set fd [open |$command]
    $log insert end $command\n
    fileevent $fd readable [list Log1 $fd $log]
  }

  proc Log1 {fd log} {
    if {[eof $fd]} {
      close $fd
      return
    }
    gets $fd line
    $log insert end $line\n
  }

I added to the Run1 proc to get:

proc Run1 {command log} {
    set fd [open |$command]
    $log insert end $command\n
    fileevent $fd readable [list Log1 $fd $log]
    vwait done <<--- added this
  }

  proc Log1 {fd log} {
    if {[eof $fd]} {
      close $fd
      set done 1
      return
    }
    gets $fd line
    $log insert end $line\n
    $log see end << --- added this
  }

Since the two programs (blaster/blastee) are C apps, and they are
stopped with Control-C, how do I get that into a proc that will kill
the processes which are local to the Run1, Log1 procs? Trying to avoid
globals :-)

Thanks again

-Al
Received on Sun Apr 30 02:21:11 2006