Class: Aggkit::ChildProcess::Unix::Process
- Inherits:
-
AbstractProcess
- Object
- AbstractProcess
- Aggkit::ChildProcess::Unix::Process
- Defined in:
- lib/aggkit/childprocess/unix/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, #status
Instance Method Summary collapse
Methods inherited from AbstractProcess
#alive?, #crashed?, #initialize, #poll_for_exit, #start, #started?
Constructor Details
This class inherits a constructor from Aggkit::ChildProcess::AbstractProcess
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
6 7 8 |
# File 'lib/aggkit/childprocess/unix/process.rb', line 6 def pid @pid end |
Instance Method Details
#exited? ⇒ Boolean
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/aggkit/childprocess/unix/process.rb', line 30 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 |
#io ⇒ Object
8 9 10 |
# File 'lib/aggkit/childprocess/unix/process.rb', line 8 def io @io ||= Unix::IO.new end |
#stop(timeout = 3) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aggkit/childprocess/unix/process.rb', line 12 def stop(timeout = 3) assert_started send_term begin return poll_for_exit(timeout) rescue TimeoutError # try next end send_kill wait rescue Errno::ECHILD, Errno::ESRCH # handle race condition where process dies between timeout # and send_kill true end |
#wait ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/aggkit/childprocess/unix/process.rb', line 49 def wait assert_started if exited? exit_code else _, status = ::Process.waitpid2 _pid set_exit_code(status) end end |