Sha256: 7c4fe31aec5526b58abf4f3177f0ee09b597c83f6e58c628cca0b2ab03664ee3

Contents?: true

Size: 1.17 KB

Versions: 56

Compression:

Stored size: 1.17 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

56 entries across 42 versions & 5 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
tdiary-5.0.13 vendor/bundle/gems/childprocess-0.9.0/lib/childprocess/jruby.rb
tdiary-5.0.12.1 vendor/bundle/gems/childprocess-0.9.0/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
childprocess-1.0.0 lib/childprocess/jruby.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
tdiary-5.0.11 vendor/bundle/gems/childprocess-0.9.0/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/childprocess-0.6.3/lib/childprocess/jruby.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/childprocess-0.9.0/lib/childprocess/jruby.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/childprocess-0.9.0/lib/childprocess/jruby.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/childprocess-0.9.0/lib/childprocess/jruby.rb