Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: warn on "hard" hard link failure
- X-seq: zsh-workers 26708
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: warn on "hard" hard link failure
- Date: Tue, 10 Mar 2009 14:18:41 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author