module PrettyMultitask::Trapper

Public Instance Methods

trap(pid) click to toggle source
# File lib/pretty_multitask/trapper.rb, line 8
def trap(pid)
  PIDS << pid
  %w[SIGINT SIGTERM SIGHUP].each do |sig|
    Signal.trap(sig) do
      begin
        PIDS.each { |pid| Process.kill sig, pid }
      rescue Errno::ESRCH
        nil
      end
    end
  end
end