zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@sunsite.dk
Subject: Re: zsh history gets destroyed when running out of disk space
Date: Sat, 23 Jun 2007 19:09:33 +0100	[thread overview]
Message-ID: <20070623190933.7af1d4b6.p.w.stephenson@ntlworld.com> (raw)
In-Reply-To: <2007-06-23T00-31-50@devnull.michael-prokop.at>

On Sat, 23 Jun 2007 00:40:09 +0200
Michael Prokop <news@michael-prokop.at> wrote:
> | zsh: failed to write history file /home/grml/.zsh_history.new: unknown error 1182546552
> 
> The error code might be improved though. ;)

Thanks for trying it.

I forgot that %e doesn't use errno directly, it expects an argument
(that's because sometimes we save the number and do something else
before reporting the error).

I've also reset errno to 0 beforehand, on the off chance that one of the
possible failures doesn't set errno.  I don't think that should happen,
but I don't want a stray ENOENT from a previous error confusing the
matter.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.67
diff -u -r1.67 hist.c
--- Src/hist.c	22 Jun 2007 20:32:20 -0000	1.67
+++ Src/hist.c	23 Jun 2007 18:05:01 -0000
@@ -2190,6 +2190,7 @@
 	if (isset(SHAREHISTORY))
 	    extended_history = 1;
     }
+    errno = 0;
     if (writeflags & HFILE_APPEND) {
 	tmpfile = NULL;
 	out = fdopen(open(unmeta(fn),
@@ -2302,10 +2303,10 @@
 
     if (ret < 0 && err) {
 	if (tmpfile) {
-	    zerr("failed to write history file %s.new: %e", fn);
+	    zerr("failed to write history file %s.new: %e", fn, errno);
 	    free(tmpfile);
 	} else
-	    zerr("failed to write history file %s: %e", fn);
+	    zerr("failed to write history file %s: %e", fn, errno);
     }
 
     unlockhistfile(fn);

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2007-06-23 18:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-11 20:22 Michael Prokop
2007-06-21  8:04 ` Frank Terbeck
2007-06-22 20:28   ` Peter Stephenson
2007-06-22 22:40     ` Michael Prokop
2007-06-23 18:09       ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070623190933.7af1d4b6.p.w.stephenson@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).