better execute_fileevent implementation

This commit is contained in:
stefan schippers 2023-03-31 14:28:59 +02:00
parent e031780f14
commit e2490034ed
1 changed files with 12 additions and 16 deletions

View File

@ -212,7 +212,6 @@ proc execute_fileevent {id} {
if {[eof $execute(pipe,$id)]} {
set report [regexp {1} $execute(status,$id)]
fileevent $execute(pipe,$id) readable ""
if { $execute(status,$id) } {
# setting pipe to blocking before closing allows to see if pipeline failed
# do not ask status for processes that close stdout/stderr, as eof might
# occur before process ends and following close blocks until process terminates.
@ -224,13 +223,10 @@ proc execute_fileevent {id} {
if {"CHILDSTATUS" == [lindex $errorCode 0]} {
set exit_status [lindex $errorCode 2]
}
if {$report} {viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"}
if {$report} {viewdata "Failed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"}
} else {
if {$report} {viewdata "Completed: $execute(cmd,$id)\ndata:\n$execute(data,$id)"}
}
} else {
close $execute(pipe,$id)
}
if {[info exists execute(callback,$id)] && $execute(callback,$id) ne {}} {
uplevel #0 "eval $execute(callback,$id)"
}