Sha256: 5b082e10fb3244dea3f657564d918af95eafe066d0584d1898d2509328c3f1f5

Contents?: true

Size: 1.12 KB

Versions: 112

Compression:

Stored size: 1.12 KB

Contents

require 'java'
require 'jruby'

class Java::SunNioCh::FileChannelImpl
  field_reader :fd
end

class Java::JavaIo::FileDescriptor
  if ChildProcess.os == :windows
    field_reader :handle
  end

  field_reader :fd
end

module ChildProcess
  module JRuby
    def self.posix_fileno_for(obj)
      channel = ::JRuby.reference(obj).channel
      begin
        channel.getFDVal
      rescue NoMethodError
        fileno = channel.fd
        if fileno.kind_of?(Java::JavaIo::FileDescriptor)
          fileno = fileno.fd
        end

        fileno == -1 ? obj.fileno : fileno
      end
    rescue
      # fall back
      obj.fileno
    end

    def self.windows_handle_for(obj)
      channel = ::JRuby.reference(obj).channel
      fileno = obj.fileno

      begin
        fileno = channel.getFDVal
      rescue NoMethodError
        fileno = channel.fd if channel.respond_to?(:fd)
      end

      if fileno.kind_of? Java::JavaIo::FileDescriptor
        fileno.handle
      else
        Windows::Lib.handle_for fileno
      end
    end
  end
end

require "childprocess/jruby/pump"
require "childprocess/jruby/io"
require "childprocess/jruby/process"

Version data entries

112 entries across 98 versions & 19 rubygems

Version Path
childprocess-3.0.0 lib/childprocess/jruby.rb
childprocess-2.0.0 lib/childprocess/jruby.rb
childprocess-1.0.1 lib/childprocess/jruby.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
tdiary-5.0.2 vendor/bundle/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
tdiary-5.0.1 vendor/bundle/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/childprocess-0.5.6/lib/childprocess/jruby.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/childprocess-0.5.6/lib/childprocess/jruby.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/childprocess-0.5.3/lib/childprocess/jruby.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/childprocess-0.5.9/lib/childprocess/jruby.rb
childprocess-0.5.9 lib/childprocess/jruby.rb
childprocess-0.5.8 lib/childprocess/jruby.rb