def forward_signals_to(pid, signals = %w[INT])
        # Set up signal handlers
        logger.debug "Setting up signal handlers for #{signals.inspect}"
        signal_count = 0
        signals.each do |signal|
          Signal.trap(signal) do
            Process.kill signal, pid rescue nil

            # If this is the second time we've received and forwarded
            # on the signal, make sure next time we just give up.
            reset_handlers_for signals if ++signal_count >= 2
          end
        end

        # Run the block now that the signals are being forwarded
        yield
      ensure
        # Always good to make sure we clean up after ourselves
        reset_handlers_for signals
      end
def forward_signals_to(pid, signals = %w[INT])
        # Set up signal handlers
        logger.debug "Setting up signal handlers for #{signals.inspect}"
        signal_count = 0
        signals.each do |signal|
          Signal.trap(signal) do
            Process.kill signal, pid rescue nil

            # If this is the second time we've received and forwarded
            # on the signal, make sure next time we just give up.
            reset_handlers_for signals if ++signal_count >= 2
          end
        end

        # Run the block now that the signals are being forwarded
        yield
      ensure
        # Always good to make sure we clean up after ourselves
        reset_handlers_for signals
      end
Forward signals to a process while running the given block

   * pid:     The process ID to forward signals to
   * signals: The names of the signals to handle (optional,
              defaults to SIGINT only)