From 9bb3e3fbe8c1dc746d307641b594d034a6ebe0ee Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 21 Dec 2009 12:15:13 -0500 Subject: [PATCH] clean up children at exit -- had about twenty processes all watching and recompiling the docs --- Rakefile | 4 +++- lib/coffee_script/command_line.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 497d07e8..87c11bee 100644 --- a/Rakefile +++ b/Rakefile @@ -18,7 +18,9 @@ end desc "Build the documentation page" task :doc do source = 'documentation/index.html.erb' - Thread.new { `bin/coffee-script documentation/cs/*.cs -o documentation/js -w` } + child = fork { exec "bin/coffee-script documentation/cs/*.cs -o documentation/js -w" } + at_exit { Process.kill("INT", child) } + Signal.trap("INT") { exit } loop do mtime = File.stat(source).mtime if !@mtime || mtime > @mtime diff --git a/lib/coffee_script/command_line.rb b/lib/coffee_script/command_line.rb index 105292dd..2c313bdf 100644 --- a/lib/coffee_script/command_line.rb +++ b/lib/coffee_script/command_line.rb @@ -65,6 +65,7 @@ Usage: sleep WATCH_INTERVAL end end + Signal.trap("INT") { watch_thread.kill } watch_thread.join end