Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [4.2.0] Src/hist.c:lockhistfile() endless loop
- X-seq: zsh-workers 19893
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: KELEMEN Peter <Peter.Kelemen@xxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: Re: [4.2.0] Src/hist.c:lockhistfile() endless loop
- Date: Fri, 7 May 2004 08:41:40 -0700
- In-reply-to: <20040507103515.GE12559@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20040507103515.GE12559@xxxxxxxxxxxxxxx>
On Fri, May 07, 2004 at 12:35:15PM +0200, KELEMEN Peter wrote:
> This looks like an endless loop if
> 1) link() fails, and
> 2) stat() returns -ENOENT.
Seems to me that the attached change would avoid the infinite loop in
the failure case you cite.
..wayne..
--- Src/hist.c 29 Oct 2003 19:17:30 -0000 1.47
+++ Src/hist.c 7 May 2004 15:39:44 -0000
@@ -2139,7 +2139,9 @@ lockhistfile(char *fn, int keep_trying)
write(fd, tmpfile+len+1, strlen(tmpfile+len+1));
close(fd);
while (link(tmpfile, lockfile) < 0) {
- if (stat(lockfile, &sb) < 0) {
+ if (errno != EEXIST)
+ ;
+ else if (stat(lockfile, &sb) < 0) {
if (errno == ENOENT)
continue;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author