aboutsummaryrefslogtreecommitdiff
path: root/examples/pipe.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pipe.tcl')
-rw-r--r--examples/pipe.tcl16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/pipe.tcl b/examples/pipe.tcl
new file mode 100644
index 0000000..6b10dbd
--- /dev/null
+++ b/examples/pipe.tcl
@@ -0,0 +1,16 @@
+lassign [socket pipe] r w
+
+# Note, once the exec has the fh (via dup), close it
+# so that the pipe data is accessible
+exec ps aux >@$w &
+$w close
+
+$r readable {
+ puts [$r gets]
+ if {[eof $r]} {
+ $r close
+ set done 1
+ }
+}
+
+vwait done