Class: ChildProcess::JRuby::Process
- Inherits:
-
AbstractProcess
- Object
- AbstractProcess
- ChildProcess::JRuby::Process
- Defined in:
- lib/childprocess/jruby/process.rb
Constant Summary
Constants inherited from AbstractProcess
AbstractProcess::POLL_INTERVAL
Instance Attribute Summary
Attributes inherited from AbstractProcess
#detach, #duplex, #environment, #exit_code
Instance Method Summary collapse
- #exited? ⇒ Boolean
-
#initialize(args) ⇒ Process
constructor
A new instance of Process.
- #io ⇒ Object
-
#pid ⇒ Fixnum
Only supported in JRuby on a Unix operating system, thanks to limitations in Java’s classes.
- #stop(timeout = nil) ⇒ Object
- #wait ⇒ Object
Methods inherited from AbstractProcess
#alive?, #crashed?, #poll_for_exit, #start
Constructor Details
#initialize(args) ⇒ Process
Returns a new instance of Process.
6 7 8 9 10 |
# File 'lib/childprocess/jruby/process.rb', line 6 def initialize(args) super(args) @pumps = [] end |
Instance Method Details
#exited? ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 false ensure log(:exit_code => @exit_code) end |
#io ⇒ Object
12 13 14 |
# File 'lib/childprocess/jruby/process.rb', line 12 def io @io ||= JRuby::IO.new end |
#pid ⇒ Fixnum
Only supported in JRuby on a Unix operating system, thanks to limitations in Java’s classes
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/childprocess/jruby/process.rb', line 51 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) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/childprocess/jruby/process.rb', line 30 def stop(timeout = nil) assert_started @process.destroy wait # no way to actually use the timeout here.. end |
#wait ⇒ Object
37 38 39 40 41 42 |
# File 'lib/childprocess/jruby/process.rb', line 37 def wait @process.waitFor stop_pumps @exit_code = @process.exitValue end |