From: Kilgallen@SpamCop.net (Larry Kilgallen)
Subject: Re: Format string bugs & race conditions
Date: 17 Oct 2004 12:28:57 -0500
Date: 2004-10-17T12:28:57-05:00 [thread overview]
Message-ID: <g6p8mwm6XMaI@eisner.encompasserve.org> (raw)
In-Reply-To: mailman.13.1098016133.10401.comp.lang.ada@ada-france.org
In article <mailman.13.1098016133.10401.comp.lang.ada@ada-france.org>, Marius Amado Alves <amado.alves@netcabo.pt> writes:
>> /* If lockfile already exists, wait until it goes away. */
>> while((p = fopen("lockfile", "r"))) {
>> fclose(p);
>> sleep(1);
>> }
>> /* (race) */
>> p = fopen("lockfile", "w");
>> /* Access the stuff which lockfile is supposed to protect from
>> * multiple access. But of course it doesn't. */
>> fclose(p);
>> remove("lockfile");
>>
>> Ada just makes it easier to implement this bug within a single
>> instance of the executable.
>
> No. Using files for locks is equally easy to implement and equally buggy
> in any language.
And that might be "not buggy at all", depending on _how_ you use files.
Regardless of programming language*, when one calls the VMS system
service SYS$CREATE with the FAB$V_CIF option a status code of
RMS$_CREATED indicates that the file was created by this process.
If not, it is time to try again for the example above. Of course
opening a file is a costly synchronization mechanism which should
only be used in cases where the cost will be dwarfed by the cost
of the operation being protected.
* As usual Ada programmers use slightly different symbol names
since Ada does not allow "$" in symbols.
next prev parent reply other threads:[~2004-10-17 17:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-16 9:28 Format string bugs & race conditions Hans Van den Eynden
2004-10-16 13:26 ` Stephen Leake
2004-10-16 15:09 ` Pascal Obry
2004-10-16 17:55 ` Jeffrey Carter
2004-10-17 5:28 ` Benjamin Ketcham
2004-10-17 9:14 ` Martin Dowie
2004-10-17 19:18 ` Benjamin Ketcham
2004-10-17 22:41 ` Martin Dowie
2004-10-18 7:57 ` Ole-Hjalmar Kristensen
2004-10-19 16:20 ` Warren W. Gay VE3WWG
2004-10-17 12:28 ` Marius Amado Alves
2004-10-17 17:28 ` Larry Kilgallen [this message]
2004-10-17 17:11 ` Larry Kilgallen
2004-10-18 0:24 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox