Blob Blame History Raw
--- rubygems-1.8.6/lib/rubygems/ext/builder.rb.insync	2011-07-27 01:14:52.000000000 +0900
+++ rubygems-1.8.6/lib/rubygems/ext/builder.rb	2011-07-27 01:15:01.000000000 +0900
@@ -11,6 +11,56 @@
     $1.downcase
   end
 
+  def self.get_status_of_forked_command(command, results)
+    read_size = 0
+
+    results << command
+    read_size += command.size
+    puts "#{command}" if Gem.configuration.really_verbose
+
+    iopipe_r, iopipe_w = IO.pipe
+
+    child_pid = fork{
+      # Child
+      $stdin.close
+      iopipe_r.close
+      $stdout.reopen(iopipe_w)
+      #  redirect
+      $stderr.reopen(iopipe_w)
+
+      exec "#{command}"
+
+      puts "Executing #{command} failed."
+      exit 127
+    }
+
+    iopipe_w.close
+    output = ""
+
+    if (child_pid < 0) then
+      raise Gem::InstallError, "Forking process of #{command} failed\n"
+    end
+
+    iopipe_r.each{|line|
+      output += line
+      if Gem.configuration.really_verbose then
+        puts "#{line}" if Gem.configuration.really_verbose
+      else
+        read_size += line.size
+        while read_size >= 128 do
+          print "."
+          $stdout.flush
+          read_size -= 128
+        end
+      end
+    }
+    results << output
+    print "\n" if not Gem.configuration.really_verbose
+
+    child_pid, status = Process.waitpid2(child_pid)
+    return status
+  end
+
   def self.make(dest_path, results)
     unless File.exist? 'Makefile' then
       raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
@@ -31,11 +81,10 @@
 
     ['', ' install'].each do |target|
       cmd = "#{make_program}#{target}"
-      results << cmd
-      results << `#{cmd} #{redirector}`
+      status = self.get_status_of_forked_command(cmd, results)
 
       raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
-        $?.success?
+        status.success?
     end
   end
 
@@ -44,10 +93,8 @@
   end
 
   def self.run(command, results)
-    results << command
-    results << `#{command} #{redirector}`
-
-    unless $?.success? then
+    status = self.get_status_of_forked_command(command, results)
+    unless status.success? then
       raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"
     end
   end
--- rubygems-1.8.6/lib/rubygems/installer.rb.insync	2011-07-27 01:14:52.000000000 +0900
+++ rubygems-1.8.6/lib/rubygems/installer.rb	2011-07-27 01:15:01.000000000 +0900
@@ -530,7 +530,7 @@
         Dir.chdir extension_dir do
           results = builder.build(extension, gem_dir, dest_path, results)
 
-          say results.join("\n") if Gem.configuration.really_verbose
+          # say results.join("\n") if Gem.configuration.really_verbose
         end
       rescue
         results = results.join "\n"