www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/25/02:23:46

Date: Wed, 25 Apr 2001 09:25:23 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Nate Eldredge <neldredge AT hmc DOT edu>
cc: djgpp AT delorie DOT com
Subject: Re: Detecting File in Use?
In-Reply-To: <83n195zxbf.fsf@mercury.st.hmc.edu>
Message-ID: <Pine.SUN.3.91.1010425092506.22758M-100000@is>
MIME-Version: 1.0
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

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019