Что произойдёт, если один скрипт читает открытый файл, а другой выполнит `unlink` этого файла?
Asked at
AI answer
On Unix-like systems, unlink removes a file's name from the directory but does not close file descriptors that are already open. A process that has already opened the file will generally continue to read it through the descriptor. A new open using the previous path will fail, and the data will be freed on disk after the last descriptor is closed and all references to the inode are removed. The behavior when deleting an open file may differ on Windows: the operation sometimes fails if the file is open without delete permission.
Also asked at Касперский
Similar questions
- What are the potential dangers of manually opening and closing files (open/close), and what happens if a file is not closed because of an error?
- What is usually used for unit tests?
- How do you navigate and work in Unix systems: how to connect and perform basic diagnostics?
- How much did you engage in less interesting tasks related to service decomposition and unit testing improvements; what were the coverage requirements?
- After implementing support for the new database system and covering the code with unit tests, what are your next steps?