module ChildProcess::JRuby

Public Class Methods

posix_fileno_for(obj) click to toggle source
# File lib/childprocess/jruby.rb, line 18
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
windows_handle_for(obj) click to toggle source
# File lib/childprocess/jruby.rb, line 35
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