]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
core: restart on SIGHUP
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 23 Apr 2008 16:33:44 +0000 (18:33 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 23 Apr 2008 17:03:11 +0000 (19:03 +0200)
lib/rbot/ircbot.rb

index 6a1c8f6758472f9ba5da84ba432b594e298947b4..9cbe7dcbedcc6bd661c1f7da72d84037485afa81 100644 (file)
@@ -761,10 +761,10 @@ class Bot
   end
 
   # things to do when we receive a signal
-  def got_sig(sig)
-    debug "received #{sig}, queueing quit"
+  def got_sig(sig, func=:quit)
+    debug "received #{sig}, queueing #{func}"
     $interrupted += 1
-    quit unless @quit_mutex.locked?
+    self.send(func) unless @quit_mutex.locked?
     debug "interrupted #{$interrupted} times"
     if $interrupted >= 3
       debug "drastic!"
@@ -778,7 +778,7 @@ class Bot
     begin
       trap("SIGINT") { got_sig("SIGINT") }
       trap("SIGTERM") { got_sig("SIGTERM") }
-      trap("SIGHUP") { got_sig("SIGHUP") }
+      trap("SIGHUP") { got_sig("SIGHUP", :restart) }
     rescue ArgumentError => e
       debug "failed to trap signals (#{e.pretty_inspect}): running on Windows?"
     rescue Exception => e