Overview
| Artifact ID: | ee07b8785ffecd717b2696bbd428a331747e65d2 |
|---|---|
| Ticket: | 218484ffffffffffffffffffffffffffffffffff
can't use [catch {close $pipe}] to get the exit status of t |
| User & Date: | nobody on 2000-10-26 01:01:07 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
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 - foundin changed to: "obsolete: 8.0.3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "60. NRE and coroutines"
- title changed to:
can't use [catch {close $pipe}] to get the exit status of t - type changed to: "Bug"