Skip to content

Commit

Permalink
Potential fix for issue defunkt#58
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgriffin committed Jul 2, 2011
1 parent 7c7ea5d commit 9047e3e
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions lib/cijoe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ def build(branch=nil)
Thread.new { build!(branch) }
end

def open_pipe(cmd)
read, write = IO.pipe

pid = fork do
read.close
$stdout.reopen write
exec cmd
end

write.close

yield read, pid
end

# update git then run the build
def build!(branch=nil)
@git_branch = branch
Expand All @@ -117,12 +103,11 @@ def build!(branch=nil)
build.branch = git_branch
write_build 'current', build

open_pipe("cd #{@project_path} && #{runner_command} 2>&1") do |pipe, pid|
puts "#{Time.now.to_i}: Building #{build.branch} at #{build.short_sha}: pid=#{pid}"

build.pid = pid
IO.popen("cd #{@project_path} && #{runner_command} 2>&1") do |io|
puts "#{Time.now.to_i}: Building #{build.branch} at #{build.short_sha}: pid=#{io.pid}"
output = io.read
build.pid = io.pid
write_build 'current', build
output = pipe.read
end

Process.waitpid(build.pid, 1)
Expand Down

0 comments on commit 9047e3e

Please sign in to comment.