   defp do_capture_io(device, options, fun) do
     input = Keyword.get(options, :input, "")
     {:ok, string_io} = StringIO.open(input)
+
     case ExUnit.CaptureServer.device_capture_on(device, string_io) do
       {:ok, ref} ->
         try do


    original_gl = Process.group_leader()
    {:ok, capture_gl} = StringIO.open(input, capture_prompt: prompt_config)
    try do
      Process.group_leader(self(), capture_gl)
      do_capture_io(capture_gl, fun)

        after
          ExUnit.CaptureServer.device_capture_off(ref)
        end

      {:error, :no_device} ->
        _ = StringIO.close(string_io)
        raise "could not find IO device registered at #{inspect(device)}"

      {:error, :already_captured} ->
        _ = StringIO.close(string_io)
        raise "IO device registered at #{inspect(device)} is already captured"
    end
  end

