in reply to Re: Update config file parameters
in thread Update config file parameters
You can do inplace editing of files:
But that introduces a race condition. The problem is documented in perlrun:
- -i[extension]
- specifies that files processed by the <> construct are to be edited in-place. It does this by renaming the input file, opening the output file by the original name, and selecting that output file as the default for print() statements.
The race: Instance 1 is started, reads the configuration file, then starts rewriting by renaming the configuration file and creating a new, still empty (or partly written) configuration file. Instance 2 is started, and reads an empty (or partly written) configuration file.
How to get rid of that problem:
(Note that safely creating temporary files is another problem: mkstemp(3) and tmpfile(3) should be safe. mktemp(3) and tmpnam(3) aren't. File::Temp has safe and unsafe functions.)
Alexander
(And yes, the problem of "disappearing configuration data" has bitten me once, and it was quite hard to find.)
|
---|