Method: Foreman::Engine#kill_children

Defined in:
lib/foreman/engine.rb

#kill_children(signal = "SIGTERM") ⇒ Object

Send a signal to all processes started by this Engine



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/foreman/engine.rb', line 189

def kill_children(signal="SIGTERM")
  if Foreman.windows?
    @running.each do |pid, (process, index)|
      system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
      begin
        Process.kill("-#{signal}", pid)
      rescue Errno::ESRCH, Errno::EPERM
      end
    end
  else
    begin
      pids = @running.keys.compact
      Process.kill("-#{signal}", *pids) unless pids.empty?
    rescue Errno::ESRCH, Errno::EPERM
    end
  end
end