Posted to tcl by stever at Mon Dec 01 23:49:23 GMT 2008view raw

  1. lassign [chan pipe] p1r p1w
  2. lassign [chan pipe] p2r p2w
  3.  
  4. proc got_stdout {chan args} {
  5. set line [read $chan 128]
  6. puts -nonewline $line
  7. }
  8.  
  9. proc got_stderr {chan args} {
  10. #gets $chan line
  11. set line [read $chan 10]
  12. puts -nonewline $line
  13. }
  14. fileevent $p1r readable "got_stdout $p1r"
  15. #fileevent $p2r readable "got_stderr $p2r"
  16.  
  17. set args "music.mp3"
  18.  
  19. set pids [exec mplayer $args >@ $p1w 2>@ $p2w &]
  20. puts $pids
  21. proc kill {args} {
  22. foreach ch $args {
  23. catch {puts $ch "q"}
  24. catch {set junk [read $ch]}
  25. catch {close $ch}
  26. }
  27. }
  28.  
  29. vwait forever