fix execute tcl procedure (correctly handle exit status of subprocesses that write to stderr but not as a failure)

This commit is contained in:
stefan schippers 2023-03-25 02:00:50 +01:00
parent fa33aca682
commit 96aa251ca0
3 changed files with 11 additions and 25 deletions

View File

@ -3389,6 +3389,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(argc > 2) tclvareval("simulate ", argv[2], NULL);
else tcleval("simulate");
}
Tcl_ResetResult(interp);
}
/* snap_wire

View File

@ -216,28 +216,15 @@ proc execute_fileevent {id} {
# do not ask status for processes that close stdout/stderr, as eof might
# occur before process ends and following close blocks until process terminates.
fconfigure $execute(pipe,$id) -blocking 1
set status 0
if { [ info tclversion] > 8.4} {
set catch_return [eval catch [list {close $execute(pipe,$id)} err options] ]
} else {
set catch_return [eval catch [list {close $execute(pipe,$id)} err] ]
}
set exit_status 0
set catch_return [eval catch [list {close $execute(pipe,$id)} err] ]
if {$catch_return} {
if {[info tclversion] > 8.4} {
set details [dict get $options -errorcode]
if {[lindex $details 0] eq "CHILDSTATUS"} {
set status [lindex $details 2]
if {$report} {viewdata "Failed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"}
} else {
set status 1
if {$report} {viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"}
}
} else {
set status 1
if {$report} {viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"}
global errorCode
if {"CHILDSTATUS" == [lindex $errorCode 0]} {
set exit_status [lindex $errorCode 2]
}
}
if {$status == 0} {
if {$report} {viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"}
} else {
if {$report} {viewdata "Completed: $execute(cmd,$id)\ndata:\n$execute(data,$id)"}
}
if {[info exists execute(callback,$id)] && $execute(callback,$id) ne {}} {
@ -248,7 +235,7 @@ proc execute_fileevent {id} {
set execute(data,last) $execute(data,$id)
set execute(error,last) $err
set execute(status,last) $execute(status,$id)
set execute(exitcode,last) $status
set execute(exitcode,last) $exit_status
unset execute(pipe,$id)
unset execute(data,$id)
unset execute(status,$id)

View File

@ -227,13 +227,11 @@ lab=TRIANG}
N 820 -280 820 -160 {
lab=0}
C {title.sym} 160 -40 0 0 {name=l1 author="Stefan Schippers" net_name=true}
C {code_shown.sym} 190 -250 0 0 {name=CONTROL value="* following line for batch mode...
.tran .05u 1m uic
* following block for interactive mode
.control
C {code_shown.sym} 190 -250 0 0 {name=CONTROL value=".control
* save all
tran .05u 1m uic
write solar_panel.raw
exit
.endc
" net_name=true}
C {code.sym} 20 -190 0 0 {name=MODELS value=".MODEL DIODE D(IS=1.139e-08 RS=0.99 CJO=9.3e-12 VJ=1.6 M=0.411 BV=30 EG=0.7 )