[fpc-pascal] (Unix) file locking

Björn Lundin b.f.lundin at gmail.com
Tue Jun 21 07:41:24 CEST 2016


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'
DESCRIPTION
Apply, test or remove a POSIX lock on a section of an open file.  The
file is specified by fd, a file descriptor open for writing, the action
by cmd, and the section consists of byte positions pos..pos+len-1 if
len  is positive,  and  pos-len..pos-1 if len is negative, where pos is
the current file position, and if len is zero,the section extends from
the current file position to infinity, encompassing the present  and
future  end-of-file positions.  In all cases, the section may extend
past current end-of-file.


It does not specify underlaying device - but you need an open file
descriptor




> 
> -- 
> The best regards,
> 
> Fabio Luis Girardi
> PascalSCADA Project
> http://sourceforge.net/projects/pascalscada
> http://www.pascalscada.com
> 
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> 


-- 
--
Björn



More information about the fpc-pascal mailing list