This is Episode 3 of The Vibe Coder’s Guide to the Machine: computer science for a new generation.
A file that has been deleted can still be downloaded in full. You can watch it happen in the small app you asked an AI for, to share files with a couple of friends: upload, list, download, delete. You upload a long video, start downloading it in one browser tab, and while the progress bar is still crawling you click Delete in another tab, to check that Delete works. It does. The video is gone from the list, and when you look in the app’s upload folder on the server it is gone from there too. Then the download carries on and finishes, because the server had already opened the file and keeps reading from what it opened. Every byte arrives, of a video that, by every account you can check, no longer exists.
Nothing broke. The delete did what you asked and so did the download. Delete ended something, only not the thing you thought. It ended a name.
Names and things end separately, and not only for files. Every thing a running program makes has its own ending. A name in a folder, the file behind it, a handle a process holds open (a handle is how a running program holds on to a file it has open), a connection to a database, an object in memory and the process itself are each ended by a particular owner, on a particular event. “It’s deleted”, “the request finished” and “the program is done” each settle exactly one of them. So the question to carry is not whether something has stopped. For each thing, ask who ends it, and by what event.
This was always true. What AI changes is who has to know it. The endings live inside the code that does the work: a block that closes a file, a pool that keeps connections, a cleanup registered for later. When you write that code by hand, you meet each ending as you type it. When an assistant writes it, the endings arrive inside libraries and services you never read, and the assistant’s “Done, I’ve deleted it” is a report about one of them.
A name and the thing it names
I tried the heart of the opening on a Mac, with Python 3.14 on macOS 26.5. The script makes a small file, opens it, deletes it while it is still open, and then reads from it. In the script, p is the file’s path, the way to find it by name, and f is the handle that opening it returns. The order of the lines is the whole point, so here they are:
with TemporaryDirectory(dir=".") as d:
p = Path(d) / "held.txt"
p.write_text("still here", encoding="utf-8")
with p.open(encoding="utf-8") as f:
p.unlink()
print("name exists:", p.exists())
print("open handle reads:", f.read())
print("handle closed:", f.closed)name exists: False
open handle reads: still here
handle closed: TrueThe first line comes after p.unlink() has removed the name: p.exists() asks whether that path still leads to a file, and it does not. The second line reads through f, the handle opened before the delete, without looking the file up by name, and gets “still here”. The last line runs outside the inner with block, as the indentation shows, and by then leaving the block has closed the handle.
A file in a folder has two parts that are easy to think of as one. There is the name, an entry in the folder that points to the file, and there is the file itself, the contents the name points to. Deleting a file removes the entry. Unix calls this unlinking, which is why Python’s method is unlink, and Apple’s manual page for it says what happens when someone is still reading: “If one or more process have the file open when the last link is removed, the link is removed, but the removal of the file is delayed until all references to it have been closed.”
The reason is that the name and the file have different holders. The folder holds the name. Any process that has opened the file holds the file. Delete takes away the folder’s hold and nothing else, so the file lasts exactly as long as anyone else still has it open. In the script, the last holder was the inner with block. When it finished, it closed the handle, and Python’s documentation promises that a file is closed when its with block ends “even if an exception occurs”. With no one left holding it, the manual page’s delayed removal could go ahead. The run shows the name going and the handle closing, and the manual page describes what follows.
That behaviour is one answer to a collision between a delete and a reader, not the only one. The Unix standard, POSIX, states the same rule: if any process has the file open when the last name is removed, “the link shall be removed before unlink() returns, but the removal of the file contents shall be postponed until all references to the file are closed.” Windows answers differently. Microsoft’s documentation says its DeleteFile “fails if an application attempts to delete a file that has other handles open for normal I/O”, unless those holders opened it allowing deletion. When they did, the file is marked “for deletion on close”: it goes only when the last handle closes, and in the meantime any new attempt to open it is refused as access denied.
Each answer buys something and pays for it. On Unix, someone holding the file open does not stop its name from being removed, and the holder is never cut off; the cost is that whoever deleted sees the name go while the data and its space live on until the last holder closes, as the video did. Windows, by default, never lets someone else’s delete take a holder’s file from under it; the cost is that the delete can be refused. Each assumes something about what a file is. Unix assumes it exists for its holders, and the folder is only a way to find it. Windows assumes a holder should be asked first.
In the file app, the difference shows up as two different requests. The upload request created the video. The download request was holding it when you clicked Delete. The creator had no say in the ending at all; the holder did. The video truly ended when the download request closed its handle, an event you never saw, caused by code you never read, some seconds after the moment you would have called it deleted.
Three things that are easy to call done
The life of a process has a beginning, a stretch of running and an end. Inside that life, three quite different things all get called “done”, and keeping them apart is most of what process lifecycle means in practice.
The first is a task completing: a request is answered, a function returns, a with block reaches its last line. The process carries on, and the task’s ending settles only what the task itself arranged to settle. The second is the process exiting, the end of the whole running instance. The third is a resource being released: something the program held, such as an open file, a connection or a lock, is actually given up, so that it can disappear or someone else can have it. These three can happen at the same moment, and often do, which is why they blur. They can also happen hours apart, caused by different parties.
Process exit is the big ending, and it is worth knowing exactly how far it reaches. When a process opens a file or a connection, the system hands it a handle, which Unix calls a file descriptor, and keeps a table of those handles for that process. Apple’s description of exit is short and firm: “All of the descriptors that were open in the calling process are closed. This may entail delays; for example, waiting for output to drain.” The reason is ownership. The handles were held through the process, so when the process is gone there is nobody left to hold them, and the system closes them on its behalf.
Read the sentence again for what it does not say. It closes descriptors. It says nothing about names in folders, or about anything a different program is keeping. Take the lock file the AI added to the price bot in the last episode: the bot creates price_bot.lock and refuses to start if that file already exists. The file’s presence is the signal that the bot is already running. The lock is a name in a folder, and the guard never says what removes it. Exit closes descriptors and leaves names alone, so the lock stays where it is after the bot stops unless the bot’s own code deletes it. If it does not, the guard will do exactly what it was written to do, to the next copy, which will be you, trying to start the bot again.
So before you trust the guard, ask the assistant one thing: what deletes price_bot.lock when the bot stops, and if the bot never gets the chance, what happens when you try to start it again?
The Vibe Coder’s Guide to the Machine. You can build it. Now understand it.



