diff --git a/src/nox.cr b/src/nox.cr index 48046e0..7260f5c 100644 --- a/src/nox.cr +++ b/src/nox.cr @@ -10,7 +10,12 @@ module Nox def self.run(file : String) procfile = Nox::Procfile.parse_file(file) runner = Nox::Runner.new(procfile, output: STDOUT) - Signal::INT.trap { runner.interrupt_or_kill } + {% if compare_versions(Crystal::VERSION, "1.8.0") < 0 %} + {% raise "Windows requires >= 1.8.0" if flag?(:win32) %} + Signal::INT.trap { runner.interrupt_or_kill } + {% else %} + ::Process.on_interrupt { runner.interrupt_or_kill } + {% end %} runner.run end end diff --git a/src/nox/process.cr b/src/nox/process.cr index b52bc96..3cd1d4c 100644 --- a/src/nox/process.cr +++ b/src/nox/process.cr @@ -28,7 +28,15 @@ class Nox::Process def kill with_process do |process| print_bold "Attempting to kill..." - process.signal(Signal::KILL) + {% if compare_versions(Crystal::VERSION, "1.8.0") < 0 %} + {% if flag?(:win32) %} + process.terminate + {% else %} + process.signal(Signal::KILL) + {% end %} + {% else %} + process.terminate(graceful: false) + {% end %} end end