at_exit handlers and Process.kill

A

ara.t.howard

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 ;)

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top