Class: ChildProcess::ProcessSpawnProcess
- Inherits:
-
AbstractProcess
- Object
- AbstractProcess
- ChildProcess::ProcessSpawnProcess
- Defined in:
- lib/childprocess/process_spawn_process.rb
Direct Known Subclasses
Constant Summary
Constants inherited from AbstractProcess
AbstractProcess::POLL_INTERVAL
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Attributes inherited from AbstractProcess
#cwd, #detach, #duplex, #environment, #exit_code, #leader
Instance Method Summary collapse
Methods inherited from AbstractProcess
#alive?, #crashed?, #initialize, #io, #poll_for_exit, #start, #started?, #stop
Constructor Details
This class inherits a constructor from ChildProcess::AbstractProcess
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/childprocess/process_spawn_process.rb', line 5 def pid @pid end |
Instance Method Details
#exited? ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/childprocess/process_spawn_process.rb', line 7 def exited? return true if @exit_code assert_started pid, status = ::Process.waitpid2(@pid, ::Process::WNOHANG | ::Process::WUNTRACED) pid = nil if pid == 0 # may happen on jruby log(:pid => pid, :status => status) if pid set_exit_code(status) end !!pid rescue Errno::ECHILD # may be thrown for detached processes true end |
#wait ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/childprocess/process_spawn_process.rb', line 26 def wait assert_started if exited? exit_code else _, status = ::Process.waitpid2(@pid) set_exit_code(status) end end |