summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b34379)
raw | patch | inline | side by side (parent: 0b34379)
author | Alex Riesen <raa.lkml@gmail.com> | |
Wed, 5 Oct 2005 14:58:11 +0000 (16:58 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 5 Oct 2005 17:50:57 +0000 (10:50 -0700) |
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>
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
index.c | patch | blob | history |
index bdde65f75c9d2a9b77e6bf290ebed57f12c8e70b..ad0eafedc288f2cf6b0d7c2493495087451ef466 100644 (file)
--- a/index.c
+++ b/index.c
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)