/sys/fs/cgroup/cpuset/ruby001/cpuset.cpus echo $$ > /sys/fs/cgroup/cpuset/ruby001/tasks cat <<RUBY | ruby - & def fib(n); n<2?1:fib(n-2)+fib(n-1); end 8.times.map do fork do loop do fib(rand(128)) end end end.each {|p| Process.waitpid p } RUBY top # then hit `1'
-n 10 vagrant@localhost:~$ ruby -e "(1..30).to_a.map { p open('/dev/urandom') }" #<File:/dev/urandom> #<File:/dev/urandom> #<File:/dev/urandom> -e:1:in `initialize': Too many open files @ rb_sysopen - /dev/urandom (Errno::EMFILE) from -e:1:in `open' from -e:1:in `block in <main>' from -e:1:in `map' from -e:1:in `<main>'