Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'open4'
- pid, stdin, stdout, stderr = Open4::popen4("ruby background.rb")
- begin
- 10.times do |n|
- puts "Foreground: #{Time.now}"
- sleep(1)
- end
- rescue Interrupt # someone did CTRL-C
- end
- def kill
- puts "Killing child"
- Process.kill(Signal.list['TERM'], pid)
- end
- at_exit do
- kill
- end
Add Comment
Please, Sign In to add comment