Project

General

Profile

Bug #3118 ยป open4_segfault.rb

simple segfault example - mkent (Matthew Kent), 04/10/2010 02:45 AM

 
1
# by masakazu tojo
2
# http://rubyforge.org/tracker/index.php?func=detail&aid=26889&group_id=1024&atid=4025
3

    
4
require "rubygems"
5
require "open4"
6
i = 0
7
loop {
8
  i += 1
9
  begin
10
    pid,stdin,stdout,stderr = Open4.popen4("cat")
11
  rescue Exception => err
12
    p err.message
13
    p err.class.to_s
14
    break
15
  end
16
  stdin.close
17
  stdout.close
18
  stderr.close
19
  Process.waitpid2(pid)
20
  puts "#{i} calls" if i % 1000 == 0
21
}