def execute(command, &block)
      logger.info "Executing command '#{command}'"
      reset
      pid, stdin, stdout_stream, stderr_stream = Open4::popen4(command)
      @pid = pid
      stdin.close rescue nil

      save_exit_status(pid)
      forward_signals_to(pid) do
        handle_streams stdout_stream, stderr_stream, &block
      end

      self
    ensure
      logger.debug "Closing stdout and stderr streams for process"
      stdout.close rescue nil
      stderr.close rescue nil
    end
def execute(command, &block)
      logger.info "Executing command '#{command}'"
      reset
      pid, stdin, stdout_stream, stderr_stream = Open4::popen4(command)
      @pid = pid
      stdin.close rescue nil

      save_exit_status(pid)
      forward_signals_to(pid) do
        handle_streams stdout_stream, stderr_stream, &block
      end

      self
    ensure
      logger.debug "Closing stdout and stderr streams for process"
      stdout.close rescue nil
      stderr.close rescue nil
    end
Initializes an Executer instance with particular options

   * options: A hash of options, with the following (symbol) keys:
      * :mode:      Controls how the process' output is given to
                    the block, one of :chars (pass each character
                    one by one, retrieved with getc), or :lines
                    (pass only whole lines, retrieved with gets).
                    (optional, defaults to :lines)
      * :no_buffer: If true, the process' stdout and stderr won't
                    be collected in the stdout and stderr
                    properties, and will only be passed to the
                    block (optional, defaults to false)
 Executes <tt>command</tt> and returns after execution

   * command: A string containing the command to run
   * block:   Gets passed stdout and stderr every time the process
              outputs to each stream (first parameter is stdout,
              second parameter is stderr; only one will contain
              data, the other will be nil)