Date: Wed, 25 Apr 2001 09:25:23 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Nate Eldredge cc: djgpp AT delorie DOT com Subject: Re: Detecting File in Use? In-Reply-To: <83n195zxbf.fsf@mercury.st.hmc.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 24 Apr 2001, Nate Eldredge wrote: > > The correct answer is: you can't reliably find out. lsof would tell > > you whether the file was open, but that could change before you get > > around to actually doing something with it. > > > > If you need to enforce some kind of sharing between applications, > > you'll need to use file locking in both of them. > > Sorry, forgot which newsgroup this was. (I was thinking of Unix.) As > far as DJGPP goes, I don't know how you find out. I don't *think* > access() will do it, but I could be wrong. You are not wrong: `access' cannot possibly tell if another application has the file open. There is subfunction 86Dh of function 440Dh of Int 21h, which can enumerate all the files open by any application, and tell the open mode of each file. But it only works on DOS 7.0 and later, and it doesn't say which application opened what file. And, of course, there's the issue of a race condition. As I said, it's hard to give a good advice without knowing what problem(s) is the OP trying to solve.