Fix retry behaviour of LibGit2 tests (#61507)
There were a few issues with it:
- `mkdir()` was used inside the retry loop, which would always fail on
the second iteration since the Example.jl directory would already exist.
- The `readuntil()` test was always returning an empty string even when
the server failed to start because `run(cmd; wait=false)` will redirect
stdio streams (including `stdout`) to `devnull`, and the `pipeline()`
call only redirected `stderr`. `open()` has the behaviour we want.
- Because `readuntil()` never blocked there was a race condition between
the process exiting and `process_running()` being called later,
sometimes causing the loop to exit early.
Tested locally by forcing it to use a specific, already in-use, port.
Should fix this failure:
https://buildkite.com/julialang/julia-master/builds/56249/steps/canvas?sid=019d5d1d-3977-47f5-9b7c-5a3b82c94674