diff --git a/Gemfile.lock b/Gemfile.lock index e9ba4e2..df77dc2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,6 +52,7 @@ GEM PLATFORMS java ruby + x86-mingw32 DEPENDENCIES aws-s3 diff --git a/lib/foreman/process.rb b/lib/foreman/process.rb index 1802dcc..b7515a1 100644 --- a/lib/foreman/process.rb +++ b/lib/foreman/process.rb @@ -30,23 +30,30 @@ private defined?(RUBY_PLATFORM) and RUBY_PLATFORM == "java" end + def windows? + defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/ + end + def fork_with_io(command, basedir) reader, writer = IO.pipe command = replace_command_env(command) - pid = if jruby? + pid = if windows? + Dir.chdir(basedir) do + Process.spawn command, :out => writer, :err => writer + end + elsif jruby? require "posix/spawn" POSIX::Spawn.spawn(Foreman.runner, "-d", basedir, command, { :out => writer, :err => writer }) else fork do - trap("INT", "IGNORE") writer.sync = true $stdout.reopen writer $stderr.reopen writer reader.close exec Foreman.runner, "-d", basedir, command - end + end end [ reader, pid ] end