File: leak.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 (17 lines) | stat: -rw-r--r-- 314 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'open4'

pid = Process.pid
fds = lambda{|pid| Dir["/proc/#{ pid }/fd/*"]}

loop do
  before = fds[pid] 
  Open4.popen4 'ruby -e"buf = STDIN.read; STDOUT.puts buf; STDERR.puts buf "' do |p,i,o,e|
    i.puts 42
    i.close_write
    o.read
    e.read
  end
  after = fds[pid] 
  p(after - before)
  puts
end