diff options
Diffstat (limited to 'code/snippets/spawn_popen_block.rb')
| -rw-r--r-- | code/snippets/spawn_popen_block.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/code/snippets/spawn_popen_block.rb b/code/snippets/spawn_popen_block.rb new file mode 100644 index 0000000..193af6a --- /dev/null +++ b/code/snippets/spawn_popen_block.rb @@ -0,0 +1,8 @@ +# An IO object is passed into the block. In this case we open the stream +# for writing, so the stream is set to the STDIN of the spawned process. +# +# If we open the stream for reading (the default) then +# the stream is set to the STDOUT of the spawned process. +IO.popen('less', 'w') { |stream| + stream.puts "some\ndata" +} |
