X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fsuicide.rb;h=98b43462eea250aa6969221d0a8456b9697bd54a;hb=b5c1bcbd4c25618574f94e683773647906f023e0;hp=5085c163c1f4f5a5005b6a87ae747d9afcd4626a;hpb=2c0bc997ecf7faa8aad3aa740624aa50473dc2c4;p=sup diff --git a/lib/sup/suicide.rb b/lib/sup/suicide.rb index 5085c16..98b4346 100644 --- a/lib/sup/suicide.rb +++ b/lib/sup/suicide.rb @@ -8,14 +8,15 @@ class SuicideManager def initialize fn @fn = fn @die = false + @thread = nil self.class.i_am_the_instance self FileUtils.rm_f @fn end bool_reader :die - def start_thread - Redwood::reporting_thread do + def start + @thread = Redwood::reporting_thread("suicide watch") do while true sleep DELAY if File.exists? @fn @@ -25,6 +26,11 @@ class SuicideManager end end end + + def stop + @thread.kill if @thread + @thread = nil + end end end