From: Nate Eldredge Newsgroups: comp.os.msdos.djgpp Subject: Re: Detecting File in Use? Date: 24 Apr 2001 16:34:44 -0700 Organization: InterWorld Communications Lines: 27 Sender: nate AT mercury DOT st DOT hmc DOT edu Message-ID: <83n195zxbf.fsf@mercury.st.hmc.edu> References: <3ae12439_2 AT rapidnet DOT net> <83snixzxgy DOT fsf AT mercury DOT st DOT hmc DOT edu> NNTP-Posting-Host: mercury.st.hmc.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: nntp1.interworld.net 988155284 55830 134.173.57.219 (24 Apr 2001 23:34:44 GMT) X-Complaints-To: usenet AT news DOT interworld DOT net NNTP-Posting-Date: Tue, 24 Apr 2001 23:34:44 +0000 (UTC) User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Nate Eldredge writes: > richard AT stardate DOT bc DOT ca (Richard Sanders) writes: > > > >How does one know if a file is ALREADY in USE by > > >some application BEFORE any actual attempt to open > > >or access that file? > > > > Check out the access(); function. > > That has nothing to do with it. > > 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. -- Nate Eldredge neldredge AT hmc DOT edu