Skip to content

Commit

Permalink
update-cache: remove index lock file on SIGINT
Browse files Browse the repository at this point in the history
This makes it a lot more pleasant to use when you
interrupt a long-running operation.
  • Loading branch information
Linus Torvalds committed Apr 26, 2005
1 parent 5697ecc commit f2a1934
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions update-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#include <signal.h>
#include "cache.h"

/*
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit f2a1934

Please sign in to comment.