Skip to content
This repository
Browse code

remove all the grit jruby hacks in favor of updated posix-spawn

  • Loading branch information...
commit 0822ea6aeef2fc0807688c5b7f0161c1c0577655 1 parent 12c9874
Aman Gupta authored June 08, 2011
5  lib/grit.rb
@@ -48,11 +48,6 @@
48 48
 require 'grit/blame'
49 49
 require 'grit/merge'
50 50
 
51  
-# platform specific requires
52  
-if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
53  
-  require 'grit/jruby'
54  
-end
55  
-
56 51
 module Grit
57 52
   VERSION = '2.4.1'
58 53
 
45  lib/grit/jruby.rb
... ...
@@ -1,45 +0,0 @@
1  
-require 'grit/process'
2  
-
3  
-module Grit
4  
-  # Override the Grit::Process class's popen4 and waitpid methods to work around
5  
-  # various quirks in JRuby.
6  
-  class Process
7  
-    # Use JRuby's built in IO.popen4 but emulate the special spawn env
8  
-    # and options arguments as best we can.
9  
-    def popen4(*argv)
10  
-      env = (argv.shift if argv[0].is_a?(Hash))  || {}
11  
-      opt = (argv.pop   if argv[-1].is_a?(Hash)) || {}
12  
-
13  
-      # emulate :chdir option
14  
-      if opt[:chdir]
15  
-        previous_dir = Dir.pwd
16  
-        Dir.chdir(opt[:chdir])
17  
-      else
18  
-        previous_dir = nil
19  
-      end
20  
-
21  
-      # emulate :env option
22  
-      if env.size > 0
23  
-        previous_env = ENV
24  
-        ENV.merge!(env)
25  
-      else
26  
-        previous_env = nil
27  
-      end
28  
-
29  
-      pid, stdin, stdout, stderr = IO.popen4(*argv)
30  
-    ensure
31  
-      ENV.replace(previous_env) if previous_env
32  
-      Dir.chdir(previous_dir)   if previous_dir
33  
-    end
34  
-
35  
-    # JRuby always raises ECHILD on pids returned from its IO.popen4 method
36  
-    # for some reason. Return a fake Process::Status object.
37  
-    FakeStatus = Struct.new(:pid, :exitstatus, :success?, :fake?)
38  
-    def waitpid(pid)
39  
-      ::Process::waitpid(pid)
40  
-      $?
41  
-    rescue Errno::ECHILD
42  
-      FakeStatus.new(pid, 0, true, true)
43  
-    end
44  
-  end
45  
-end

0 notes on commit 0822ea6

Please sign in to comment.
Something went wrong with that request. Please try again.