[fpc-devel] does fpc lock the fpc.cfg exclusive on windows?

Marco van de Voort marcov at stack.nl
Sat Aug 28 12:25:27 CEST 2010


In our previous episode, Jonas Maebe said:

> > But *if* fpc does lock the fpc.cfg file exclusively ( for a very short
> > time only, e.g.  just open+lock, read, close), then there is the slim
> > chance of a conflict, and this error could be explained.
> 
> FPC opens it as a regular text file using a regular assign/reset. I don't
> think that will result in exclusive access.  It also checks for its
> existence using sysutils.fileexists, but I doubt that one asks for
> exclusive access either.

Doesn't that depend on filemode? I see a lot of places in the compiler where
it is read/changed/preserved:

comprsrc.pas:  oldfmode:=Filemode;
comprsrc.pas:  Filemode:=0;
comprsrc.pas:  Filemode:=oldfmode;
cstreams.pas:  oldfilemode : byte;
cstreams.pas:      oldfilemode:=filemode;
cstreams.pas:      filemode:=$40 or Mode;
cstreams.pas:      filemode:=oldfilemode;
finput.pas:        ofm:=filemode;
finput.pas:        filemode:=0;
finput.pas:        filemode:=ofm;
impdef.pas:  OldFileMode:longint;
impdef.pas:  OldFileMode:=filemode;
impdef.pas:   filemode:=0;
impdef.pas:   filemode:=OldFileMode;
ppu.pas:  ofmode:=filemode;
ppu.pas:  filemode:=$0;
ppu.pas:  filemode:=ofmode;
ppu.pas:    ofm:=filemode;
ppu.pas:    filemode:=0;
ppu.pas:    filemode:=ofm;

None of them in options. So there could be something to it, specially since
it is so early in the startup.

Hmm,

I did a quick writeln(filemode) just before the config file was opened, and
it printed 2, read/write (the default.



More information about the fpc-devel mailing list