I have a script that starts up a DRb service, before spawning a handler object and waiting via DRb.thread.join
. I would like the script to run until explicitly killed, so I added
trap "INT" do
DRb.stop_service
end
which successfully stops the DRb service and exits under Ruby 1.8, but under 1.9 seems to deadlock (on OS X 10.6.7). Sampling the process shows a couple of threads spinning in semaphore_wait_signal_trap
.
I assume that I'm doing something wrong in the way I'm calling stop_service
, but I'm not sure what. Could anyone give me any pointers around how to correctly go about it?
Okay, I think I have found the solution. If I replace the original code with
begin
DRb.thread.join
rescue Interrupt
ensure
DRb.stop_service
end
The Ctrl-C works and stops the service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With