mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 00:02:23 +00:00
Every zsh pane gets a throwaway ZDOTDIR under the temp directory, four redirector files in it, and the pane's own teardown removes it — stop a server cleanly and it leaves none. A server that is killed never runs that teardown, and nothing ever goes back to look: this machine had 3,850 of them, from months of crashes and `kill -9`s. Same shape as the socket a killed daemon used to leave behind, and the same answer: a later startup is the only thing in a position to notice, so it sweeps beside the endpoint cleanup. Timid on purpose. A directory goes only when the name is exactly ours, the pid in it parses, and that pid is not a live process — so a running daemon's directories are never touched, and a pid since reused by something else just waits for another day. Verified after the sweep: 3,850 down to 14, and every one of those 14 belongs to a live process, the installed tty7.app's daemon among them. `process_alive` was wrong about that, which the test caught. `kill(pid, 0) == 0` is only half the answer: `EPERM` means the process exists and belongs to someone else, and reading that as dead would have had the sweep delete a live owner's directory. Both callers wanted the other reading — one decides whether to clean up after a daemon, the other whether to delete its files. The two tests that bind an endpoint now hold a lock while they do. `set_config_dir` is first-wins, so every test in the process shares one socket path, and the one added here made the pair flaky together while each passed alone.