Class: ChildProcess::Unix::Process
- Inherits:
-
AbstractProcess
- Object
- AbstractProcess
- ChildProcess::Unix::Process
- Defined in:
- lib/childprocess/unix/process.rb
Constant Summary
Constant Summary
Constants inherited from AbstractProcess
AbstractProcess::POLL_INTERVAL
Instance Attribute Summary (collapse)
-
- (Fixnum) pid
readonly
The pid of the process after it has started.
Attributes inherited from AbstractProcess
Instance Method Summary (collapse)
-
- (Boolean) exited?
Did the process exit?.
- - (Object) io
- - (Object) stop(timeout = 3)
Methods inherited from AbstractProcess
#alive?, #crashed?, #initialize, #poll_for_exit, #start
Constructor Details
This class inherits a constructor from ChildProcess::AbstractProcess
Instance Attribute Details
- (Fixnum) pid (readonly)
The pid of the process after it has started
7 8 9 |
# File 'lib/childprocess/unix/process.rb', line 7 def pid @pid end |
Instance Method Details
- (Boolean) exited?
Did the process exit?
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/childprocess/unix/process.rb', line 37 def exited? return true if @exit_code assert_started pid, status = ::Process.waitpid2(@pid, ::Process::WNOHANG) log(:pid => pid, :status => status) if pid @exit_code = status.exitstatus || status.termsig end !!pid end |
- (Object) io
9 10 11 |
# File 'lib/childprocess/unix/process.rb', line 9 def io @io ||= Unix::IO.new end |
- (Object) stop(timeout = 3)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/childprocess/unix/process.rb', line 13 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 |