X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=index.c;h=f92b960ae46b2d43b2f46693fe086a4c4dbe3737;hb=1d84a60459a32fb1707ff7de4a013b5d9673f55d;hp=87fc7b0387b818001fb0e53fdb713fe1bad4f822;hpb=07ee0d77c66d6f356cd3f82435e67510779aa53c;p=git.git diff --git a/index.c b/index.c index 87fc7b03..f92b960a 100644 --- a/index.c +++ b/index.c @@ -18,18 +18,22 @@ static void remove_lock_file(void) static void remove_lock_file_on_signal(int signo) { remove_lock_file(); + signal(SIGINT, SIG_DFL); + raise(signo); } int hold_index_file_for_update(struct cache_file *cf, const char *path) { + int fd; sprintf(cf->lockfile, "%s.lock", path); - cf->next = cache_file_list; - cache_file_list = cf; - if (!cf->next) { + fd = open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0666); + if (fd >=0 && !cf->next) { + cf->next = cache_file_list; + cache_file_list = cf; signal(SIGINT, remove_lock_file_on_signal); atexit(remove_lock_file); } - return open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0600); + return fd; } int commit_index_file(struct cache_file *cf)