summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-26 11:55:42 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-26 11:55:42 -0700
commitf2a19340ada1188e278d5b198d3466ed7411e2d4 (patch)
tree96d0f92b2a67b32696811fd7e285979018ad8498
parent5697ecc7be275f884d4f843d0f77f19de2eb604c (diff)
downloadgit-f2a19340ada1188e278d5b198d3466ed7411e2d4.tar.gz
update-cache: remove index lock file on SIGINT
This makes it a lot more pleasant to use when you interrupt a long-running operation.
-rw-r--r--update-cache.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/update-cache.c b/update-cache.c
index 02c213cfb6..e759c647a7 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+#include <signal.h>
#include "cache.h"
/*
@@ -299,6 +300,11 @@ static void remove_lock_file(void)
unlink(lockfile_name);
}
+static void remove_lock_file_on_signal(int signo)
+{
+ remove_lock_file();
+}
+
int main(int argc, char **argv)
{
int i, newfd, entries;
@@ -312,6 +318,7 @@ int main(int argc, char **argv)
if (newfd < 0)
die("unable to create new cachefile");
+ signal(SIGINT, remove_lock_file_on_signal);
atexit(remove_lock_file);
lockfile_name = lockfile;