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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.45.138 with SMTP id n10mr5166912obm.4.1440688522867; Thu, 27 Aug 2015 08:15:22 -0700 (PDT) X-Received: by 10.182.105.34 with SMTP id gj2mr74405obb.34.1440688522842; Thu, 27 Aug 2015 08:15:22 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!se8no11355085igc.0!news-out.google.com!nt1ni16621igb.0!nntp.google.com!u8no1060669igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 27 Aug 2015 08:15:22 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:1205:c69a:d430:e8cd:61ae:7524:899d; posting-account=DQbqYQoAAACn8hHn2LmG2aF7Mhbxl_Lf NNTP-Posting-Host: 2a02:1205:c69a:d430:e8cd:61ae:7524:899d References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8cbeb0d0-0c55-4502-875b-a0fe0d23e13d@googlegroups.com> Subject: Re: Exclusive file access From: ahlan@marriott.org Injection-Date: Thu, 27 Aug 2015 15:15:22 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:27622 Date: 2015-08-27T08:15:22-07:00 List-Id: I've read the manual and (to my reading) it gives the impression that the second opening should raise an exception. If I try to open the file twice within the same process then it works as expected but NOT if the file is opened twice from different processes. I can get it to work under Windows if I do my own IO using the windows API directly but of course that is not exactly portable and rather defeats the point of having Ada.Text_Io. Is this a Gnat bug? Gautier wrote it works as expected under ObjectAda. On Thursday, August 27, 2015 at 4:48:56 PM UTC+2, G.B. wrote: > 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.)