From: Robert Klemme Date: 2005-06-02T19:20:23+09:00 Subject: Re: trap HUP not working wmwilson01@gmail.com wrote: > I know I must be doing something dumb here, but I can't figure out > what, and I'm about to give up. I'm setting a trap("HUP") to call a > couple of functions (basically to re-read a config). The first time > running a "kill -HUP" on the process works fine, but the second time > it exits with a "hangup". If I modify the trap to look like: > > trap("HUP") { > trap("HUP", "IGNORE") > fun1 > fun2 > } > > It doesn't hangup, but only the first "kill -HUP" actually re-reads > the configuration. You surprise me: you are really surprised that only the first signal is processed? I mean, you set the signal handler to IGNORE on first run and apparently you never reset it. As far as I can see signal handlers are never executed concurrently but if you want to be sure, I'd use standard thread synchronization: require 'thread' $HUP_LOCK = Mutex.new trap "HUP" do $HUP_LOCK.synchronize do puts "your code here (queued up)" end if $HUP_LOCK.try_lock puts "your code here (ingore duplicate invocations)" $HUP_LOCK.unlock end end Kind regards robert