Skip to content

Commit

Permalink
use spawn instead of exec
Browse files Browse the repository at this point in the history
  • Loading branch information
alexch committed Nov 10, 2015
1 parent e3aaa30 commit cf2ae08
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/rerun/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ def force_polling
end

def start
if windows?
raise "Sorry, Rerun does not work on Windows."
end

if @already_running
taglines = [
"Here we go again!",
Expand All @@ -153,14 +149,13 @@ def start
clear_screen if clear?
start_keypress_thread unless @keypress_thread

@pid = Kernel.fork do
begin
exec(@run_command)
rescue => e
puts "#{e.class}: #{e.message}"
exit
end
begin
@pid = run @run_command
rescue => e
puts "#{e.class}: #{e.message}"
exit
end

status_thread = Process.detach(@pid) # so if the child exits, it dies

Signal.trap("INT") do # INT = control-C -- allows user to stop the top-level rerun process
Expand Down Expand Up @@ -209,6 +204,10 @@ def start
end
end

def run command
Kernel.spawn command
end

def change_message(changes)
message = [:modified, :added, :removed].map do |change|
count = changes[change] ? changes[change].size : 0
Expand Down

0 comments on commit cf2ae08

Please sign in to comment.