Project

General

Profile

Bug #15423 ยป fork_leapfrog_freebsd.rb

normalperson (Eric Wong), 12/16/2018 02:28 PM

 
require 'io/wait'
prev = 0
100000.times do
pid = fork
exit!(0) if pid

# show the RSS (FreeBSD 11.x)
n = IO.popen("ps -u #$$", &:readlines)[1].split[5].to_i
if n > prev
puts "#{prev} => #{n}"
prev = n
end

# since Ctrl-C from a terminal can't stop this loop,
# allow the user to just mash the keyboard to stop
break if STDIN.wait(0)
end
    (1-1/1)