On Thu, Jun 16, 2011 at 12:41 PM, Jerry Feldman <g...@gapps.blu.org> wrote: > One possible solution that seems to work. In my wrapper script: > <command> --arg1 --arg2.... 2>&1 > > And in the tcl script: > > if [catch {open "|$command"} input] { > > I still get my zombie on the start command, but I query the open file list in > tcl (file channels) and close any open files other than stdxxx. > > It's fun trying to write production code when you don't know the language :-)
The section in the man page for open called COMMAND PIPELINES doesn't really spell it out. The `open` command returns a file descriptor. You need to close that file descriptor to wait for the process. Here's a quick demo: #!/usr/bin/tclsh # This produces a zombie, the file descriptor is "lost". if [catch {open "|echo foo"} input] { puts "something went wrong: $input" } puts "Press ctrl-z now and do a ps to check for zombies" after 3000 # This does not: if [catch {set f [open "|echo bar"]} input] { puts "something else went wrong: $input" } # (The zombie is here.) puts "Press ctrl-z now and do a ps to check for zombies" after 3000 close $f # (And now it's not.) puts "Press ctrl-z now and do a ps to check for zombies" after 3000 # Closing the file descriptor from this `open` will cause an error. # (See the man page.) if [catch {set f [open "|/bin/false"]} input] { puts "something different went wrong: $input" } close $f HTH. -- Brian St. Pierre _______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/