On 2025-08-28, Roel Schroeven <r...@roelschroeven.net> wrote: >> If an OS did let you delete an open file, how would you expect it to >> behave? Would you still be able to use the file? Would the file be >> marked for deletion and be deleted when it was finally closed?
> Unix-like operating systems do let you delete an open file. It then > disappears from directory listings, To clarify: it only disappears from the one directory from which you deleted it. Removing a file that exists in multiple directories will not cause it to disappear from any of the other directories. > but is not actually deleted until the last process that has an open > handle to the file closes that handle (or exits, in which case the > handle is closed automatically). Right. On Linux/Unix the 'rm' operation merely removes the link from the directory to the inode. The underlying filesystem won't 'delete' the actual file (inode and associated storage blocks) unless that was the only link to the inode and there are no open file handles associated with the inode. When the total number of links/handles drops to zero, then the filesystem will 'delete' the file. -- https://mail.python.org/mailman3//lists/python-list.python.org