Project

General

Profile

Bug #15423 ยป fork_leapfrog_freebsd.rb

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

 
1
require 'io/wait'
2
prev = 0
3
100000.times do
4
  pid = fork
5
  exit!(0) if pid
6

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

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