** Synopsis ** === [package require] Tcl 8.6 [lassign] [['''chan pipe''']] readChanId writeChanId ... [close] $readChanId; [close] $writeChanId === ** Description ** Creates a standalone anonymous ''operating system'' 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 [http://tip.tcl.tk/304.html] 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). <> [aspect]: Sounds similar in application to [String channels], which works on 8.4/5 at least. [kostix] comments: [aspect], I doubt this: pipes [[chan pipe]] creates are ''operating system objects'' which have real handles hidden behind Tcl channels. So when you, for instance, redirect the stdin of a spawned process to the pipe, on the OS level the handle of the process stdin will be the read handle of the OS pipe. And this is the OS who transports the data over such a pipe between Tcl channels. [aspect]: Right you are .. string channels are a much more simple-minded facility, and not nearly as useful. ---- [AMG]: [[chan pipe]] can be used to access the [stderr] of an [[[open] |]] [pipeline]. ====== lassign [chan pipe] rderr wrerr set stdio [open |[concat $command [list 2>@ $wrerr]] a+] # write to $stdio -> pipeline's stdin # read from $stdio <- pipeline's stdout # read from $rderr <- pipeline's stderr ====== <> ---- !!!!!! %|[Category Command] of [Tcl] 8.6 |[Category Channel]|% !!!!!!