www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/06/03:30:19

Date: Tue, 6 Apr 1999 09:28:14 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Vic <tudor AT cam DOT org>
cc: djgpp AT delorie DOT com
Subject: Re: file locking
In-Reply-To: <37094AE1.229A@cam.org>
Message-ID: <Pine.SUN.3.91.990406092755.6187I-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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.

- Raw text -


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