Version 5 of chan pipe

Updated 2008-09-20 12:26:27 by kostix

Synopsis

 package require Tcl 8.6
 lassign [chan pipe] readChanId writeChanId
 ...
 close $readChanId; close $writeChanId

Description

Creates a standalone anonymous pipe and returns a pair of channel handles for its read and write ends, in this order.

The most useful way to use such pipes is to redirect standard channel(s) of a process to be run using [exec ... &] in which case it becomes possible to close the stdin of the spawned process forcing it to detect EOF and exit while collecting what it writes on its stdout/stderr. For instance, the tclgpg extension makes heavy use of this technique to control the gpg binary being executed.

This subcommand was introduced by TIP #304 [L1 ] and is mostly a rip of the pipe command implementation from Tclx.

Availability

The implementation is available in Tcl >= 8.6.

kostix has created a TEA-based extension out of this implementation called tclpipe. It can be used with (supposedly) any version of Tcl (tested on 8.4 and 8.5).