Commit eca9f99
committed
Ensure the port isn't open before our
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.)git daemon
1 parent 39a1cc7 commit eca9f99
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | | - | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
0 commit comments