Posted to tcl by mjanssen at Tue Feb 02 10:29:34 GMT 2021view raw
- proc util::exec_tail {args} {
- # On platforms with `kill`, we can print the output produced by a
- # process while it's running. Uses globals and vwait, so only one
- # at a time.
- set args [lsearch -all -inline -not -exact $args "-ignorestderr"]
- set ::done 0
- set ::tmp [open "| $args 2>@1"]
- chan configure $::tmp -blocking 0 -buffering none
- chan event $::tmp readable {
- set l [chan read $::tmp]
- if {![chan eof $::tmp]} {
- puts -nonewline $l
- flush stdout
- } else {
- set ::done 1
- }
- }
- vwait ::done
- chan close $::tmp
- unset ::done
- unset ::tmp
- }
Comments
Posted by anticrisis at Tue Feb 02 18:13:06 GMT 2021 [text] [code]
Thank you, open to a pipe is so much cleaner!