diff --git a/lockfile.c b/lockfile.c
index 2a2fea3cb6bd1de059e7c0f8c2008c5fe8376b93..731bbf3c9c312687714d19391e6e02ffde8eaebd 100644 (file)
--- a/lockfile.c
+++ b/lockfile.c
/*
* Copyright (c) 2005, Junio C Hamano
*/
-#include <signal.h>
#include "cache.h"
static struct lock_file *lock_file_list;
sprintf(lk->filename, "%s.lock", path);
fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
if (0 <= fd) {
- if (!lk->next) {
+ if (!lk->on_list) {
lk->next = lock_file_list;
lock_file_list = lk;
+ lk->on_list = 1;
+ }
+ if (lock_file_list) {
signal(SIGINT, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
return error("cannot fix permission bits on %s",
lk->filename);
}
+ else
+ lk->filename[0] = 0;
return fd;
}