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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c71bf3c5adc59b21 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!k37g2000hsf.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Opening a file vs. creating if not yet exists Date: Thu, 21 Aug 2008 14:06:35 -0700 (PDT) Organization: http://groups.google.com Message-ID: <919bcbea-3eac-41dd-b784-e1b2eff6e252@k37g2000hsf.googlegroups.com> References: <87k5edjd6y.fsf@nbi.dk> <48AD8CBE.5060801@users.sourceforge.net> NNTP-Posting-Host: 85.3.252.233 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1219352796 8915 127.0.0.1 (21 Aug 2008 21:06:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 21 Aug 2008 21:06:36 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k37g2000hsf.googlegroups.com; posting-host=85.3.252.233; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7469 Date: 2008-08-21T14:06:35-07:00 List-Id: On 21 Sie, 17:41, Martin Krischik wrote: > > The atomicity of the complete solution is not an issue, since there is > > no chance for the log file to be deleted by some other entity. > > Realy no chance? Did you consider > > rm -rf *.log Yes, and this is not an issue for the reason of hazards. Since the action of removing files this way would be asynchronous with regards to the logging program, we should really protect against calling it in both cases: "just before" opening the file as well as "just after". The latter is a problem - no amount of trickery in the program (atomic or not) can protect this case and if that happens the log file becomes invisible (except for the program which would keep the only, but unnamed, link to the file) and the file would vanish at the program exit. Not very useful. That's why we have to either assume that this never happens - and then the first case need no protection - or that it is hopeless anyway. Nothing to do in either case. (the above assumes POSIX, Windows may behave differently) > Ok I am pulling your leg here. Sure. That's what makes usenet more funny. :-) -- Maciej Sobczak * www.msobczak.com * www.inspirel.com Database Access Library for Ada: www.inspirel.com/soci-ada