Date: Tue, 6 Apr 1999 09:28:14 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Vic cc: djgpp AT delorie DOT com Subject: Re: file locking In-Reply-To: <37094AE1.229A@cam.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 5 Apr 1999, Vic wrote: > First of all, is there an ANSI file locking function (or posix) > or a fuction that works under UNIX GCC? If there's no such function in DJGPP, you can be sure it's neither ANSI nor Posix. Otherwise, DJGPP would have it, at least as a stub. The DJGPP library has `lock' and `unlock' (and also MSC-compatible `_dos_lock' and `_dos_unlock') which implement file locking. I believe the library docs describe these functions adequately. Unix has `lockf' and `flock', which are similar but present a different interface. Please type "man lockf" and "man flock" on a Unix box to read their documentation. It would be nice, btw, if you could implement `lockf' and/or `flock' for DJGPP using the DOS/Windows functionality presented in `lock' and `unlock'; the Unix functionality is quite similar, so this shouldn't be a large undertaking. > second of all, if you lock a file and another instance tries to write to > it, what happens? how can you see if a file or region is locked? On DOS/Windows or on Unix? On Unix, the other process which tries to write blocks until the file is unlocked. On DOS/Windows I think the write call fails, but you'll need to try to make sure.