Skip to content

Commit f2a1934

Browse files
author
Linus Torvalds
committed
update-cache: remove index lock file on SIGINT
This makes it a lot more pleasant to use when you interrupt a long-running operation.
1 parent 5697ecc commit f2a1934

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

update-cache.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Copyright (C) Linus Torvalds, 2005
55
*/
6+
#include <signal.h>
67
#include "cache.h"
78

89
/*
@@ -299,6 +300,11 @@ static void remove_lock_file(void)
299300
unlink(lockfile_name);
300301
}
301302

303+
static void remove_lock_file_on_signal(int signo)
304+
{
305+
remove_lock_file();
306+
}
307+
302308
int main(int argc, char **argv)
303309
{
304310
int i, newfd, entries;
@@ -312,6 +318,7 @@ int main(int argc, char **argv)
312318
if (newfd < 0)
313319
die("unable to create new cachefile");
314320

321+
signal(SIGINT, remove_lock_file_on_signal);
315322
atexit(remove_lock_file);
316323
lockfile_name = lockfile;
317324

0 commit comments

Comments
 (0)