From cbe2cb353c82ce38caf3f58185dd7fb46897f554 Mon Sep 17 00:00:00 2001 From: slavic Date: Sun, 24 Apr 2011 20:21:39 +0300 Subject: [PATCH] fix issue #27 --- lib/guard/interactor.rb | 48 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/lib/guard/interactor.rb b/lib/guard/interactor.rb index f5247eb..32dab08 100644 --- a/lib/guard/interactor.rb +++ b/lib/guard/interactor.rb @@ -1,29 +1,41 @@ module Guard module Interactor - - def self.init_signal_traps + + def self.init_signal_traps # Run all (Ctrl-\) - Signal.trap('QUIT') do - ::Guard.run do - ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) } + if Signal.list.has_key?('QUIT') + Signal.trap('QUIT') do + ::Guard.run do + ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) } + end end + else + UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work" end - + # Stop (Ctrl-C) - Signal.trap('INT') do - UI.info "Bye bye...", :reset => true - ::Guard.listener.stop - ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) } - abort("\n") - end - - # Reload (Ctrl-Z) - Signal.trap('TSTP') do - ::Guard.run do - ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) } + if Signal.list.has_key?('INT') + Signal.trap('INT') do + UI.info "Bye bye...", :reset => true + ::Guard.listener.stop + ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) } + abort("\n") end + else + UI.info "Your system doesn't support INT signal, so Ctrl-C (stop) won't work" + end + + # Reload (Ctrl-Z) + if Signal.list.has_key?('TSTP') + Signal.trap('TSTP') do + ::Guard.run do + ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) } + end + end + else + UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work" end end - + end end \ No newline at end of file