[fpc-pascal] (Unix) file locking
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Tue Jun 21 10:17:26 CEST 2016
Björn Lundin wrote:
> On 2016-06-21 00:37, Fabio Luis Girardi wrote:> > > 2016-06-20 18:15 GMT-03:00 Björn Lundin <b.f.lundin at gmail.com> <mailto:b.f.lundin at gmail.com>>:> > > on Linux and AIX I use lockf.> then read() and write() from the os.> However I lock the whole file, but the manpage says it is possible to> lock parts of it.> > > > This can be used to lock character devices, like /dev/ttyUSB0?> > FPC fpFLock does the same than Posix.Lockf?
>
> that I do not know.from 'man lockf'DESCRIPTIONApply, test or remove a POSIX lock on a section of an open file. Thefile is specified by fd, a file descriptor open for writing, the actionby cmd, and the section consists of byte positions pos..pos+len-1 iflen is positive, and pos-len..pos-1 if len is negative, where pos isthe current file position, and if len is zero,the section extends fromthe current file position to infinity, encompassing the present andfuture end-of-file positions. In all cases, the section may extendpast current end-of-file.
>
> It does not specify underlaying device - but you need an open filedescriptor
The interesting question is what functions that translates to in Pascal
(specifically, FPC). I suspect FpFcntl() and FpRead() etc. rather than
anything higher-level (e.g. streams).
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list