From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-users-return-23677-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 9fecd834 for ; Sun, 23 Sep 2018 19:40:47 +0000 (UTC) Received: (qmail 2577 invoked by alias); 23 Sep 2018 19:40:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23677 Received: (qmail 27237 invoked by uid 1010); 23 Sep 2018 19:40:29 -0000 X-Qmail-Scanner-Diagnostics: from joooj.vinc17.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(155.133.131.76):SA:0(-1.9/5.0):. Processed in 3.232884 secs); 23 Sep 2018 19:40:29 -0000 X-Envelope-From: vincent@vinc17.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Date: Sun, 23 Sep 2018 21:40:19 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: No fsync on history file? I lost my history Message-ID: <20180923194018.GA18586@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20180923085246.GA19251@lilyforest.localdomain> <1537709747.103981.1517680056.72C7A43E@webmail.messagingengine.com> <20180923142255.GA4931@lilyforest.localdomain> <1537714011.118073.1517716184.0B2E8824@webmail.messagingengine.com> <20180923152546.GA6201@lilyforest.localdomain> <1537717517.130522.1517748104.07A63DB4@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1537717517.130522.1517748104.07A63DB4@webmail.messagingengine.com> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.10.1+96 (4350694b) vl-108074 (2018-09-18) On 2018-09-23 15:45:17 +0000, Daniel Shahaf wrote: > > > > +++ b/Src/hist.c > > > > @@ -2933,6 +2933,9 @@ savehistfile(char *fn, int err, int writeflags) > > > > lasthist.text = ztrdup(start); > > > > } > > > > } > > > > + fflush(out); /* need to flush before fsync */ > > > > > > Isn't the fflush() on line 2927 sufficient? (Even if it isn't, I would have > > > expected a ret>=0 guard around this call.) > > > > It should call write(2) to write out the buffered data. Then the kernel > > can fsync the data to disk. A guard has been added. > > Yes, I understand that fflush(3) must be called in order to flush data > from libc's buffers into kernel buffers, which fsync(2) will later flush > to disk. My question was whether the fflush() call being added was > redundant because of the existing call on line 2927. It would be odd > to have two fflush() calls in a row without fwrite() between them; and > to have only one of them update lasthist. But the first one is in a "if", thus might have not been called. Or there is an inconsistency in the conditions, which should be fixed. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)