    # File lib/amqp/ext/emfork.rb, line 14
    def EM.fork num = 1, &blk
      unless @forks
        trap('CHLD') {
          pid = Process.wait
          p [:pid, pid, :died] if EMFORK
          block = @forks.delete(pid)
          EM.fork(1, &block)
        }

        trap('EXIT') {
          p [:pid, Process.pid, :exit] if EMFORK
          @forks.keys.each { |pid|
            p [:pid, Process.pid, :killing, pid] if EMFORK
            Process.kill('USR1', pid)
          }
        }

        @forks = {}
      end

      num.times do
        pid = EM.fork_reactor do
          p [:pid, Process.pid, :started] if EMFORK

          trap('USR1') { EM.stop_event_loop }
          trap('CHLD') {}
          trap('EXIT') {}

          blk.call
        end

        @forks[pid] = blk
        p [:children, EM.forks] if EMFORK
      end
    end