3 ms·
> You can close the handle the other program holds on the file, it just might crash that other program. It might do more than just crash that other program. So
by cesarb 7y ago
> You can close the handle the other program holds on the file, it just might crash that other program.
It might do more than just crash that other program. Some other component within that program might open a new file (or even things which are not really files), and happen to get the same handle you had just closed (once the handle is closed, its number can be reused). Then the original component finishes what it was doing and closes the handle; the second component thinks it's still open. A third component opens a new file, and again gets the same handle. Now the second component tries to write to the handle (it might be something like a log file), and the write goes to the wrong place.
Force closing a handle on a different process leads to undefined behavior, and as always with undefined behavior, anything can happen.
Raymond Chen also has an article about this: http://technet.microsoft.com/en-us/magazine/2009.04.windowsconfidential.aspx http://technet.microsoft.com/en-us/magazine/2009.04.windowsc...