Module: Death::Killer

Defined in:
lib/death/killer.rb

Class Method Summary collapse

Class Method Details

.kill(signal, pid, *pids) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/death/killer.rb', line 6

def kill(signal, pid, *pids)
  command = "kill #{[signal, pid, pids].flatten.compact.shelljoin}"

  Open3.popen3(command) do |stdin, stdout, stderr|
    msg = stderr.read
    if /kill: illegal process id: kill/ === msg
      puts 'death: illegal process id: kill'
    else
      puts "#{msg.gsub(/kill/, 'death')}"
    end
  end
end