From: Tim Pease Date: 2008-04-16T23:51:15+09:00 Subject: Re: at_exit handlers and Process.kill On Apr 15, 2008, at 7:10 PM, ara.t.howard wrote: > > On Apr 15, 2008, at 11:25 AM, Tim Pease wrote: >> 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 > > cleanup = lambda do > cleanup = lambda{} > p 'cleanup' > end > That's not going to work. The various exit handlers already have a reference to the cleanup proc, so reassigning the cleanup variable will not prevent it from getting called twice. I know that global variables are ugly, but there is a time and a place for everything. And it's way too clever for me ;) TwP