defbacktrace_for_all_threads(signame)File.open("/tmp/ruby_backtrace_#{Process.pid}.txt","a")do|f|f.puts"--- got signal #{signame}, dump backtrace for all threads at #{Time.now}"ifThread.current.respond_to?(:backtrace)Thread.list.eachdo|t|f.puts"--------------------------------------------------------------------"f.putst.backtraceendelsef.putscallerendendendSignal.trap(29)dobacktrace_for_all_threads("INFO")end