Class: ChildProcess::Unix::Process

Inherits:
AbstractProcess
  • Object
show all
Defined in:
lib/childprocess/process.rb

Instance Method Summary collapse

Instance Method Details

#return_unless_timeoutObject


5
6
7
8
9
10
11
12
# File 'lib/childprocess/process.rb', line 5

def return_unless_timeout
  lambda do |timeout|
    begin
      return poll_for_exit timeout
    rescue TimeoutError
    end
  end
end

#stop(timeout = 3, signal = nil) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/childprocess/process.rb', line 14

def stop(timeout = 3, signal=nil)
  assert_started

  unless signal.nil?
    send_signal signal
    return_unless_timeout.call(timeout)
  end

  send_term
  return_unless_timeout.call(timeout)

  send_kill
  wait
rescue Errno::ECHILD, Errno::ESRCH  # handle race condition where process dies between timeout
  # and send_kill

  true
end