From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Exclusive file access Date: Thu, 27 Aug 2015 16:48:55 +0200 Organization: A noiseless patient Spider Message-ID: References: Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 27 Aug 2015 14:47:09 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="b96887e80893c84a90c3007226ca0d1c"; logging-data="8946"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/m5v9xdJMUoC9LJtNL5uwnZtxXNWVczLE=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: Cancel-Lock: sha1:VMdvGeAVAuYE8m42qLgOZMVhjHU= Xref: news.eternal-september.org comp.lang.ada:27620 Date: 2015-08-27T16:48:55+02:00 List-Id: On 27.08.15 15:52, ahlan@marriott.org wrote: > Dear All, > > Obviously I'm misunderstanding something here. > > I thought that if two processes tried to open the same file for write access then the second process would get an exception. > > I have a simple example which when compiled using GnatPro 7.3.1 and run under 32-bit Windows XP demonstrates that this is not so. > > Which then begs the question on how to detect if the file is in use and abort if it is. > This should be simple but obviously too complex for my tiny brain. > Does anyone know how to do this from Ada (without resorting to the OS directly)? GNAT RM, section "11.10 Shared Files" addresses this for GNAT GPL; GNAT Pro should have a similar/the same section. (The manual is installed with the compiler, e.g. in the share/doc/gnat subdirectory.)