From: Linus Torvalds Date: Tue, 26 Apr 2005 18:55:42 +0000 (-0700) Subject: update-cache: remove index lock file on SIGINT X-Git-Tag: v0.99~738 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f2a19340ada1188e278d5b198d3466ed7411e2d4;p=git.git update-cache: remove index lock file on SIGINT This makes it a lot more pleasant to use when you interrupt a long-running operation. --- diff --git a/update-cache.c b/update-cache.c index 02c213cfb..e759c647a 100644 --- a/update-cache.c +++ b/update-cache.c @@ -3,6 +3,7 @@ * * Copyright (C) Linus Torvalds, 2005 */ +#include #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;