As you've discovered, when working with pipelines in Tcl, you can encounter an error condition if:[ul][li]one of the programs in the pipeline exits with a non-zero exit code, or[/li][li]one of the programs writes to its standard error ([tt]stderr[/tt]) channel and
you don't explicitly redirect [tt]stderr[/tt] when you create the pipeline.[/li][/ul]This error is usually thrown when you attempt to
close the channel. So it's a good policy to
always catch your
close when working with pipes in Tcl.
Without seeing the code, it's a bit difficult to advise the best approach to take. But it's basically going to be either
catch the
close (which I recommend regardless), and/or tell
open how you want [tt]stderr[/tt] handled in your pipeline. You could redirect [tt]stderr[/tt] to a file, redirect it to another open file descriptor, discard it by redirecting it to
/dev/null, or merge it with the [tt]stdout[/tt] channel, in which case it will show up interleaved with the rest of your program's output.
Several of these techniques are explained on the Tcl'ers Wiki (
You might try starting with the pages "open,"
and "stderr,"
Another option you might consider, if it's feasible in your situation, is to use the
bgerror command from the
BLT extension. It has some really nice features for dealing with external programs, including managing the [tt]stderr[/tt] channel. You can find out more information at "bgerror,"
and "BLT,"
- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax