Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure the port isn't open before our
git daemon
If a previous run of the git daemon still has port 9418 open, then we might think we successfully ran `git daemon`, when instead our asynchronous command could be failing to bind the port and quitting immediately. (The use of `set -e` would not mitigate this, since the `git daemon ... &` command would have successfully forked off the asynchronous subprocess.) One way that could happen, at least in principle, is if the `EXIT` trap from a previous run did not cause the `git-daemon` process to terminate. That could happen either due to: - The `EXIT` trap somehow not running. - The child `git-daemon` process not being caused to terminate when its parent `git` process terminates. They are actually separate processes: Running a `git daemon ...` command creates a `git` process, which then creates a `git-daemon` subprocess (where `git-daemon` is in the `git-core` directory `git --exec-path` gives). The parent `git` process forks before exec-ing the child `git-daemon` process. So they have separate PIDs. The PID from `$!` belongs to the parent `git` process. However, both processes are usually terminated, at least in simplified local experiments. This change aims to detect such conditions. (It might be worth keeping even if that kind of problem is not currently happening.)
- Loading branch information