Mail Archives: djgpp/1999/04/06/03:30:19
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 -