[fpc-pascal] Is System.IOResult thread-safe? (If not, I need to replace it.)

Vinzent Höfler JeLlyFish.software at gmx.net
Sat Nov 20 01:15:13 CET 2010


On Fri, 19 Nov 2010 23:02:11 +0100, Cox, Stuart TRAN:EX  
<Stuart.Cox at gov.bc.ca> wrote:

> I think the easiest way to get cross-platform lockfile behaviour, is to
> a) create the lockfile at the start of your program (e.g., a rewrite
> followed by a close)
> b) whenever you want to lock it, use
>
> systutils.fileopen(lockfilename,fmOpenWrite or fmShareExclusive);
>
> If that function returns -1, acquiring the lock failed.

This is bound to fail if someone deleted the lock file in between.

Something similar happened here with some commercial tool we use. It
then refused to open, because "another user already locked it".

Just thought, I mention it. No need to duplicate other's people mistakes.  
;)


Vinzent.



More information about the fpc-pascal mailing list