Below my little program for Linux (because I use ps command)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
require ‘socket’
Thread.abort_on_exception=true
pid=Process.fork do
##Processus 1
thread=Thread.new do
tcp_server = TCPServer.new(‘0.0.0.0’,10000)
socket = tcp_server.accept
end
thread.join
end
#Porcessus 2
while true
output=’’
IO.popen(“ps -p #{pid} -o pcpu,size”) do |pipe|
output=pipe.read
end
puts output
sleep(1)
end
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
When I execute this program (with ruby 1.8.7 or 1.9.2) and after 10
steps, I can see process 1 consumes CPU, why ?