Class: ChildProcess::JRuby::Process

### Home Classes Methods

### In Files

- lib/childprocess/jruby/process.rb

### Parent

ChildProcess::AbstractProcess

### Methods

- ::new
- #exited?
- #io
- #pid
- #stop
- #wait

### Class/Module Index

Quicksearch

- ChildProcess
- ChildProcess::AbstractIO
- ChildProcess::AbstractProcess
- ChildProcess::Error
- ChildProcess::InvalidEnvironmentVariable
- ChildProcess::JRuby
- ChildProcess::JRuby::IO
- ChildProcess::JRuby::Process
- ChildProcess::JRuby::Pump
- ChildProcess::LaunchError
- ChildProcess::MissingPlatformError
- ChildProcess::SubclassResponsibility
- ChildProcess::TimeoutError
- ChildProcess::Tools
- ChildProcess::Tools::Generator
- ChildProcess::Unix
- ChildProcess::Unix::ForkExecProcess
- ChildProcess::Unix::IO
- ChildProcess::Unix::Lib
- ChildProcess::Unix::Lib::Attrs
- ChildProcess::Unix::Lib::FileActions
- ChildProcess::Unix::Platform
- ChildProcess::Unix::PosixSpawnProcess
- ChildProcess::Unix::PosixSpawnProcess::Argv
- ChildProcess::Unix::PosixSpawnProcess::Envp
- ChildProcess::Unix::Process
- ChildProcess::Windows
- ChildProcess::Windows::Handle
- ChildProcess::Windows::IO
- ChildProcess::Windows::IoCounters
- ChildProcess::Windows::JobObjectBasicLimitInformation
- ChildProcess::Windows::JobObjectExtendedLimitInformation
- ChildProcess::Windows::Lib
- ChildProcess::Windows::Process
- ChildProcess::Windows::Process::Job
- ChildProcess::Windows::ProcessBuilder
- ChildProcess::Windows::ProcessInfo
- ChildProcess::Windows::SecurityAttributes
- ChildProcess::Windows::StartupInfo
- Java
- Java::JavaIo
- Java::JavaIo::FileDescriptor
- Java::SunNioCh
- Java::SunNioCh::FileChannelImpl
- FFI
- FFI::MemoryPointer

No matching classes.

# ChildProcess::JRuby::Process

### Public Class Methods

new(args) click to toggle source

    # File lib/childprocess/jruby/process.rb, line 6
    def initialize(args)
      super(args)

      @pumps = []
    end

### Public Instance Methods

exited?() click to toggle source

    # File lib/childprocess/jruby/process.rb, line 16
    def exited?
      return true if @exit_code

      assert_started
      @exit_code = @process.exitValue
      stop_pumps

      true
    rescue java.lang.IllegalThreadStateException => ex
      log(ex.class => ex.message)
      false
    ensure
      log(:exit_code => @exit_code)
    end

io() click to toggle source

    # File lib/childprocess/jruby/process.rb, line 12
    def io
      @io ||= JRuby::IO.new
    end

pid() click to toggle source

Only supported in JRuby on a Unix operating system, thanks to limitations in Java's classes

@return [Fixnum] the pid of the process after it has started @raise [NotImplementedError] when trying to access pid on non-Unix platform

    # File lib/childprocess/jruby/process.rb, line 56
    def pid
      if @process.getClass.getName != "java.lang.UNIXProcess"
        raise NotImplementedError, "pid is only supported by JRuby child processes on Unix"
      end

      # About the best way we can do this is with a nasty reflection-based impl
      # Thanks to Martijn Courteaux
      # http://stackoverflow.com/questions/2950338/how-can-i-kill-a-linux-process-in-java-with-sigkill-process-destroy-does-sigter/2951193#2951193
      field = @process.getClass.getDeclaredField("pid")
      field.accessible = true
      field.get(@process)
    end

stop(timeout = nil) click to toggle source

    # File lib/childprocess/jruby/process.rb, line 31
    def stop(timeout = nil)
      assert_started

      @process.destroy
      wait # no way to actually use the timeout here..
    end

wait() click to toggle source

    # File lib/childprocess/jruby/process.rb, line 38
    def wait
      if exited?
        exit_code
      else
        @process.waitFor

        stop_pumps
        @exit_code = @process.exitValue
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.