diff options
author | Alex Riesen <raa.lkml@gmail.com> | 2005-10-05 16:58:11 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-10-05 10:50:57 -0700 |
commit | d6e548d61fa95b98e98b3c1e592a4d73aa308969 (patch) | |
tree | 755ada28d210daa8128a54494a9e2097a9531c48 /index.c | |
parent | 0b34379a8da82061308b7a22d0caa1834d579f48 (diff) | |
download | git-d6e548d61fa95b98e98b3c1e592a4d73aa308969.tar.gz git-d6e548d61fa95b98e98b3c1e592a4d73aa308969.tar.xz |
[PATCH] hold_index_file_for_update should not unlink failed to open .lock files atexit
Set up atexit only if the .lock-file was opened successfully.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'index.c')
-rw-r--r-- | index.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -22,14 +22,16 @@ static void remove_lock_file_on_signal(int 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, 0666); + return fd; } int commit_index_file(struct cache_file *cf) |