Project

General

Profile

Backport #7720 ยป daemon.rb

benweint (Ben Weintraub), 01/22/2013 02:33 AM

 
#!/usr/bin/env ruby

Thread.new do
loop do
puts "background thread in #{$$} woke"
sleep(1)
end
end

sleep(2)

if ARGV[0] == 'fork'
puts "#{$$} forking"
Process.fork
else
puts "#{$$} daemonizing"
Process.daemon(true, true)
end

puts "#{$$} exiting with #{Thread.list.size} Ruby threads"
    (1-1/1)