← Adobe Interview InsightsSoftware Engineer
I knew the broad strokes: rm unlinks the directory entry but the inode stays alive while open file descriptors hold a reference.
Walk through the Unix file model: separate the directory entry, inode, and open file description, then trace each actor (writer, tailer, rm) against that model. Emphasize that the inode persists while any process holds an open descriptor, and use that to explain the tailer's continued reads, the writer's continued writes, and the df/du discrepancy.
Pro tip: Mention that the tailer keeps reading because it holds an open file descriptor to the inode, not the path — and that this is exactly why log rotation tools use copytruncate or signal the writer to reopen the file. Also note that `lsof +L1` is the faster way to find deleted-but-open files than `lsof | grep deleted`.
Explain that a file is a directory entry pointing to an inode, and that open file descriptors reference the inode, not the path. This separation is the key to the entire answer.
The writer's file descriptor remains valid because it points to the inode, which still has a link count of 1 (the open fd). Writes continue to the same inode and are appended normally; the writer sees no error.
The tailer also holds an open fd to the same inode, so it continues to read newly written data. It does not notice the unlink because it never re-resolves the path.
rm removes the directory entry and decrements the inode's link count to 0, but the inode is not freed while open fds remain. The inode becomes anonymous and is only reclaimed when the last fd is closed.
Disk space is freed only when the last fd closes. Until then, df shows the space as used while du (which walks the directory tree) does not see the file, creating the classic df/du mismatch. lsof | grep deleted (or lsof +L1) reveals the deleted-but-open inode.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.