1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 21:44:11 +01:00

Fix the potential for an infinite loop in lockhistfile() if the

link() calls fails for some other reason than EEXIST.
This commit is contained in:
Wayne Davison 2004-05-11 21:45:36 +00:00
parent c00fdaa3f0
commit 1ec2b5c096

@ -2139,11 +2139,13 @@ 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 || !keep_trying)
;
else if (stat(lockfile, &sb) < 0) {
if (errno == ENOENT)
continue;
}
else if (keep_trying) {
else {
if (time(NULL) - sb.st_mtime < 10)
sleep(1);
else