This commit is contained in:
slavic 2011-04-24 20:21:39 +03:00
parent a0b6ecacdb
commit cbe2cb353c

View File

@ -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