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
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/childprocess-4.1.0/lib/childprocess/jruby.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
childprocess-4.1.0 lib/childprocess/jruby.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/childprocess-3.0.0/lib/childprocess/jruby.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/childprocess-4.0.0/lib/childprocess/jruby.rb