def handle_stderr(stream)
      @err_array = []
      # synchronize access to @err_array
      @semaphore = Mutex.new
      Thread.new do
        until (line = stream.gets).nil?
          line.strip!
          @semaphore.synchronize { @err_array << line if line.size > 3 }
        end
      end
    end
def handle_stderr(stream)
      @err_array = []
      # synchronize access to @err_array
      @semaphore = Mutex.new
      Thread.new do
        until (line = stream.gets).nil?
          line.strip!
          @semaphore.synchronize { @err_array << line if line.size > 3 }
        end
      end
    end
Start new thread that will read stderr given as stream
 and add errors into @err_array.