删除包含客户端当前正在下载的文件的目录

Imagine the following scenario:

  • Client (browser) calls a PHP script
  • Script generates a ZIP file in web_root/downloads/tmp/test.zip
  • Script returns headers accordingly and therefore initiates a download of that ZIP file
  • Script terminates the directory web_root/downloads/tmp/

What could happen?

  1. Server queues deletion and deletes folder as soon as possible
  2. Directory (and file) are deleted and the client therefore loses the connection
  3. Server declines deletion because directory is somehow locked
  4. Apache actually clones/caches files before streaming them, so that deleting the original will have no effect

Which one is correct?

Now, i could test this behaviour on my own server, but what i want to know is whether there exists any sort of convention that defines UNIX/LINUX based standard behaviour in such a case?

How are such cases handled in general?

5. Apache has the filesystem inode open, so when you delete the file, it's not deleted, it's unlinked. That is, link web_root/downloads/tmp/test.zip is removed, but the inode still exists as long as apache has the inode open. When apache closes the inode, its link count reaches zero and is removed by the system