File: stdin_timeout.rb

package info (click to toggle)
ruby-open4 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 184 kB
  • sloc: ruby: 806; makefile: 2
file content (9 lines) | stat: -rw-r--r-- 284 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
require 'open4'

producer = 'ruby -e" STDOUT.sync = true; loop{sleep(rand+rand) and puts 42} " 2>/dev/null'

consumer = 'ruby -e" STDOUT.sync = true; STDIN.each{|line| puts line} "'

open4(producer) do |pid, i, o, e|
  open4.spawn consumer, 0=>o, 1=>STDOUT, :stdin_timeout => 1.4
end