Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: No fsync on history file? I lost my history
- X-seq: zsh-users 23673
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: lilydjwg <lilydjwg@xxxxxxxxx>
- Subject: Re: No fsync on history file? I lost my history
- Date: Sun, 23 Sep 2018 14:46:51 +0000
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=PPRNE9 5aEg4V6HgsEiz0V7CdcfncyZ/FZmHnmWISDgE=; b=bXG1rj2YosLc4jD/Ehzuqc m6L+kP0pqiff9ZOKiPPLHfaV9gKN/ZU3so+foHPGFb8Q4uGXlq4pZ+S34CNnR8Iw F8jiFVpQG6FyjIoFZKVX4GeRCp8saG4UokIP3+prhlI1w8C2sb4oJdaZAW5+v0Mx r2M7038wx3yVcFg56wmVLZeIHhx4bqlLN25fgIA34SzOsB/Y4OOBZGLtHOFK6TgM bZiB8N6XyUBYsli4iZ8NMpqmoZNKa7uAngKAheTjsYXb5lafjyHAIG1WJDG2Kkej q0z11Yy7h5IRDAGlgu1a0qeYnimfBY4LfbNzUU1+fUOuBmFK9Cld2A5fzR+A/67Q ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=PPRNE9 5aEg4V6HgsEiz0V7CdcfncyZ/FZmHnmWISDgE=; b=oK/gOECFdvhiokOw6TiuCQ 8aKi7/x3fqelgg+9+D5AojLaLzbo501AaZO5/GGqmmfMJMI1qNBJcsh15fBJ9fB/ EzIh/6kGGoEA2JrHjvpDwDU1W8I3HSY5ExjtNmSy7GytzY2IxpB0JR1XXMMgY0wT qMJpoKSmB7a2HKYKw6fAaQxGCY+bAEAvHtfDTDcMCEYfr44QAmaa8HgEUBH3qpoR HCOJs+ubPXn9cQ2+GIVZhjzreHFkP8FIlBWFD3fHFFLnLOHQo+XXVhUfLT5bZ43e hwj7WwxeDd9skQwaMYepG+EO6lfbeh0gZnzJ5huwizdSOx/aZfKaDhDb0Wj23Xtw ==
- In-reply-to: <20180923142255.GA4931@lilyforest.localdomain>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20180923085246.GA19251@lilyforest.localdomain> <1537709747.103981.1517680056.72C7A43E@webmail.messagingengine.com> <20180923142255.GA4931@lilyforest.localdomain>
lilydjwg wrote on Sun, 23 Sep 2018 22:22 +0800:
> Here it is. I've checked that it works on my Linux system, but not sure
> about other systems.
fsync() is in POSIX. I assume we can just call it, but if somebody complains
we'll need to use an HAVE_FSYNC guard.
> +++ 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.)
> + if (fsync(fileno(out)) < 0 && ret >= 0)
> + ret = -1;
fileno() can return -1.
Shouldn't the ret>=0 check happen before the calls to fileno() and fsync()?
> if (fclose(out) < 0 && ret >= 0)
> ret = -1;
> if (ret >= 0) {
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author