tags:

views:

45

answers:

1

Disclaimer: I am mainly a linux/web developer.

Windows has this "nice" feature where it denies permission to delete any file that is held open by any process. So if an antivirus hits the wrong file at the wrong time, some random program might misbehave and possibly crash.

Am I right? Are there plans to fix this?

Do any of you find this acceptable, or, how could it possibly seem a good idea at the time?

Edit:

It works very differently on Unix, and has been so for decades.

As an example:

  • process 1 opens foo.txt, for read or write, or both, doesn't matter
  • process 2 deletes the file
  • the file is unlinked from the filesystem
  • process 1 keeps reading and/or writing, the file still exists, and it can grow as long as there's room on the disk. It's just not reachable from other processes that have not already a file handle to it.
  • when process 1 closes the file, it won't be accessible from anywhere

Actually, a common usage pattern for temporary files on Unix is: open-remove-read/write-close.

A: 

This is perfectly acceptable. Imagine a situation where you're reading a database file in your application, and some other application comes along and deletes that database file from right under you. How does your application know to check that the file still exists? How will it ensure that the file stream does not all of a sudden attempt to read that file may be there one millisecond, but not the next? This is why programs can lock files, to ensure that the file will always be there until the program determines that it is done with it.

It may be more helpful to tell us why this file locking is undesirable in your situation. I'm pretty sure anti-virus programs do an optimistic lock on files, unless it's cleaning them.

Daniel T.
It's like pulling the foundation out from underneath a house.
Nathan W
edited for clarity
Marco Mariani
Every file I/O operation can signal an error, so unless you've been sloppy about checking them, there would be no additional check to perform.
Pete Kirkham
Nothing happens for those who have the file already open - no read or write errors.
Marco Mariani
On a Linux filesystem, deleting a file only deletes its entry in the directory listing. The file is only really deleted once all the file descriptors for that file have been closed. As far as applications that have already opened the file are concerned, the file is still there, so "[deleting] database file from right under you" isn't a problem. (Of course, the data will be deleted once the application closes the file descriptor, but that's the responsibility of the application deleting the file, not a problem for the application that was using it.)
Bruno