summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-23 18:33:44 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-04-23 19:03:11 +0200
commit2c7bb309e9b81c18665c7d6e09c2a68ea5e1180e (patch)
tree9855153d20d66a38c025dc5fe0bc5e724e635ee0
parent9adfc94657f2cb502705696c649a6bf849555970 (diff)
core: restart on SIGHUP
-rw-r--r--lib/rbot/ircbot.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 6a1c8f67..9cbe7dcb 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -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