From: Tim Pease Date: 2008-04-16T02:25:02+09:00 Subject: Re: at_exit handlers and Process.kill On Apr 15, 2008, at 10:58 AM, Daniel Berger wrote: > > > Yes, Guy, I understand that. You aren't listening. > > How do I create an all purpose cleanup handler within a Ruby program > that will fire off no matter how the script is terminated? > > Thanks, > cleanup = lambda { next if $cleanup_was_already_done $cleanup_was_already_done = true # your cleanup code goes here } Signal.list.values.each do |signal| Signal.trap(signal,&cleanup) end at_exit &cleanup Blessings, TwP