master/lib/guard/interactor.rb
Rémy Coutable b34cd1acfb Based on @ttilley explanation in https://github.com/thibaudgg/rb-fsevent/issues/17, signal handlers registration should happen before any subprocess creation (fsevent_watch for instance) to be properly catches by the subprocess.
Note that in the case when guard is run via bundler, this –quoting @ttilley– "would make this an unsolvable problem" (isn't it dramatic?! ;)).
2011-07-30 23:58:53 +02:00

55 lines
1.2 KiB
Ruby

module Guard
module Interactor
extend self
def run_all
::Guard.run do
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
end
end
def stop
UI.info "Bye bye...", :reset => true
::Guard.listener.stop
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
abort
end
def reload
::Guard.run do
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
end
end
def self.init_signal_traps
# Run all (Ctrl-\)
if Signal.list.has_key?('QUIT')
Signal.trap('QUIT') do
run_all
end
else
UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work"
end
# Stop (Ctrl-C)
if Signal.list.has_key?('INT')
Signal.trap('INT') do
stop
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
reload
end
else
UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work"
end
end
end
end