At_exit handlers and Process.kill

On Apr 16, 2008, at 8:51 AM, Tim P. wrote:

cleanup = lambda do
And it’s way too clever for me :wink:
the whole code:

cfp:~ > cat a.rb
cleanup = lambda do
cleanup = lambda{}
p :cleanup
end

Signal.trap(‘HUP’){ cleanup.call }
Signal.trap(‘USR1’){ cleanup.call }

Process.kill ‘HUP’, Process.pid
Process.kill ‘USR1’, Process.pid

cfp:~ > ruby a.rb
:cleanup

just avoids needing an external/global switch…

a @ http://codeforpeople.com/

On Apr 15, 2008, at 7:10 PM, ara.t.howard wrote:

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 :wink:

TwP

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs