How to programmatically determine from a process P, which other process P' has a lock on a file, that prevents P from recreating that file ?
I know there are tools to do that, but how do they achieve that ?
(Context: a batch program that runs overnight fails because of a locked file. Running an admin tool the next day may be too late to get useful information. So it would be nice if the batch program itself was able to determine the culprit.)
EDIT: Added complexity: the file resides on a DFS and P' might not run on the same machine as P (but maybe does). But a solution that works locally would be a good beginning.