Module: PrettyMultitask::Trapper

Defined in:
lib/pretty_multitask/trapper.rb

Class Method Summary collapse

Class Method Details

.trap(pid) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# 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