zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: warn on "hard" hard link failure
Date: Tue, 10 Mar 2009 14:18:41 +0000	[thread overview]
Message-ID: <2106.1236694721@csr.com> (raw)

This is reponse to Sourceforge issue 1968395: failures to create hard
links aren't gracefully handled.  Failing to create a link because the
file already exists is the normal condition being handled by the locking
code; however, a failure for any other reason is presumably a hard
failure worthy of reporting.  The same goes if stat() fails with
anything other than ENOENT: in both cases we give up and should say so.

It's possible this can be improved further.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.87
diff -u -r1.87 hist.c
--- Src/hist.c	25 Feb 2009 10:30:15 -0000	1.87
+++ Src/hist.c	10 Mar 2009 14:15:07 -0000
@@ -2433,13 +2433,16 @@
 	    } else
 		close(fd);
 	    while (link(tmpfile, lockfile) < 0) {
-		if (errno != EEXIST || !keep_trying)
+		if (errno != EEXIST)
+		    zerr("failed to create hard link as lock file %s: %e",
+			 lockfile, errno);
+		else if (!keep_trying)
 		    ;
 		else if (stat(lockfile, &sb) < 0) {
 		    if (errno == ENOENT)
 			continue;
-		}
-		else {
+		    zerr("failed to stat lock file %s: %e", lockfile, errno);
+		} else {
 		    if (time(NULL) - sb.st_mtime < 10)
 			sleep(1);
 		    else


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


             reply	other threads:[~2009-03-10 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10 14:18 Peter Stephenson [this message]
2009-11-14 16:18 Clint Adams
2009-11-14 17:32 ` François Revol

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=2106.1236694721@csr.com \
    --to=pws@csr.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).