summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-19 01:31:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-12-21 09:56:20 (GMT)
commit0693f9ddad3d9af3d3424087557bbddce480ce3f (patch)
treebee18d67e504137396ed341f4c847391b0b298fe
parentc55fae43c4e10e2779e4fb7d70d6f6e4a7645a63 (diff)
downloadgit-0693f9ddad3d9af3d3424087557bbddce480ce3f.zip
git-0693f9ddad3d9af3d3424087557bbddce480ce3f.tar.gz
git-0693f9ddad3d9af3d3424087557bbddce480ce3f.tar.bz2
Make sure lockfiles are unlocked when dying on SIGPIPE
We cleaned up lockfiles upon receiving the usual suspects HUP, TERM, QUIT but a wicked user could kill us of asphyxiation by piping our output to a pipe that does not read. Protect ourselves by catching SIGPIPE and clean up the lockfiles as well in such a case. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--lockfile.c1
-rwxr-xr-xt/t3600-rm.sh17
2 files changed, 18 insertions, 0 deletions
diff --git a/lockfile.c b/lockfile.c
index 6d75608..8589155 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -140,6 +140,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)
signal(SIGHUP, remove_lock_file_on_signal);
signal(SIGTERM, remove_lock_file_on_signal);
signal(SIGQUIT, remove_lock_file_on_signal);
+ signal(SIGPIPE, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
lk->owner = getpid();
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index b7d46e5..95542e9 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -251,4 +251,21 @@ test_expect_success 'refresh index before checking if it is up-to-date' '
'
+test_expect_success 'choking "git rm" should not let it die with cruft' '
+ git reset -q --hard &&
+ H=0000000000000000000000000000000000000000 &&
+ i=0 &&
+ while test $i -lt 12000
+ do
+ echo "100644 $H 0 some-file-$i"
+ i=$(( $i + 1 ))
+ done | git update-index --index-info &&
+ git rm -n "some-file-*" | :;
+ test -f .git/index.lock
+ status=$?
+ rm -f .git/index.lock
+ git reset -q --hard
+ test "$status" != 0
+'
+
test_done