mirror of
https://github.com/git/git
synced 2024-10-28 19:25:47 +00:00
[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>
This commit is contained in:
parent
0b34379a8d
commit
d6e548d61f
1 changed files with 6 additions and 4 deletions
6
index.c
6
index.c
|
@ -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 hold_index_file_for_update(struct cache_file *cf, const char *path)
|
||||||
{
|
{
|
||||||
|
int fd;
|
||||||
sprintf(cf->lockfile, "%s.lock", path);
|
sprintf(cf->lockfile, "%s.lock", path);
|
||||||
|
fd = open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0666);
|
||||||
|
if (fd >=0 && !cf->next) {
|
||||||
cf->next = cache_file_list;
|
cf->next = cache_file_list;
|
||||||
cache_file_list = cf;
|
cache_file_list = cf;
|
||||||
if (!cf->next) {
|
|
||||||
signal(SIGINT, remove_lock_file_on_signal);
|
signal(SIGINT, remove_lock_file_on_signal);
|
||||||
atexit(remove_lock_file);
|
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)
|
int commit_index_file(struct cache_file *cf)
|
||||||
|
|
Loading…
Reference in a new issue