|
2001-04-05
| ||
| 08:20 | • Ticket [218484ffff] can't use catch {close $pipe} to get the exit status ... artifact: 3fa1f1c9c3 user: dgp | |
|
2000-10-26
| ||
| 08:23 | • Closed ticket [218484ffff]. artifact: 8ea5da08c8 user: welch | |
| 01:01 | • New ticket [218484ffff]. artifact: ee07b8785f user: nobody | |
can't use [catch {close $pipe}] to get the exit status of t
Closed / Fixed218484ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:01:07
OriginalBugID: 692 Bug
Version: 8.0.3
SubmitDate: '1998-10-02'
LastModified: '1999-12-03'
Severity: SER
Status: Released
Submitter: hershey
ChangedBy: hobbs
OS: All
OSVersion: NA
Machine: NA
FixedDate: '1999-12-03'
FixedInVersion: 8.0.5
ClosedDate: '2000-10-25'
Following examples discussed in c.l.t, and documented at
<URL: ftp://ftp.neosoft.com/pub/tcl/sorted/text/tclarch.txt>, I've
been using [open |] + [fileevent] for inter-process communication,
and I've used [catch {close $pipe}] to get the exit status of the
child process. I'm sad to report that this mechanism is broken
in Tcl 8.0.3, as the following short example will demonstrate:
visage:tmp: cat child.tcl
#!/bin/sh
# exec tclsh "$0" ${1+"$@"}
puts stderr "Msg to stderr"
puts stdout "Msg to stdout"
exit 1
visage:tmp: cat parent.tcl
#!/bin/sh
# exec tclsh "$0" ${1+"$@"}
puts "Tcl patch level: [info patchlevel]"
proc Handler {f} {
if {[gets $f line]<0} {
global ExecDone errorCode
if {[catch {close $f} res]} {
set ExecDone [list 1 $res $errorCode]
} else {
set ExecDone [list 0]
}
return
}
puts $line
}
set f [open [concat | 2>@ stderr child.tcl] r]
fileevent $f readable [list Handler $f]
vwait ExecDone
if {[lindex $ExecDone 0]} {
puts stderr "ERROR: [lindex $ExecDone 1]"
puts stderr "CODE: [lindex $ExecDone 2]"
}
visage:tmp: ./parent.tcl
Tcl patch level: 8.0p2
Msg to stderr
Msg to stdout
ERROR: child process exited abnormally
CODE: CHILDSTATUS 3299 1
sycamore:tmp: ./parent.tcl
Tcl patch level: 8.0.3
Msg to stderr
Msg to stdout
This inconsistency breaks existing scripts, and seemingly prevents
a parent process from gathering the exit status of its child when
they are connected via a pipeline.
Don Porter
Results from 8.0.5:
op [~/tmp/auto] 140 % ./parent.tcl
Tcl patch level: 8.0.5
Msg to stderr
Msg to stdout
ERROR: child process exited abnormally
CODE: CHILDSTATUS 16122 1
As desired.
-- 12/03/1999 hobbs
welch Closed ticket [218484ffff].
[History diff]2000-10-26 08:23:17
dgp Ticket [218484ffff]: 3 changes
[History diff]2001-04-05 08:20:13
Log in (anonymous is fine) to add a comment.