summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Paolo Bonzini <bonzini@gnu.org>2008-05-29 16:55:53 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-05-31 14:33:59 -0700
commitad5fa3cc0e115a8b111868af2f727322feb144cb (patch)
tree09d7ab5a909bd1cc63e2ce3be8cacf73324fcaf9
parentRevision walking documentation: document most important functions (diff)
downloadtgif-ad5fa3cc0e115a8b111868af2f727322feb144cb.tar.xz
rollback lock files on more signals than just SIGINT
Other signals are also common, for example SIGTERM and SIGHUP. This patch modifies the lock file mechanism to catch more signals. It also modifies http-push.c which was missing SIGTERM. Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--http-push.c1
-rw-r--r--lockfile.c3
-rwxr-xr-xt/t7502-commit.sh14
3 files changed, 18 insertions, 0 deletions
diff --git a/http-push.c b/http-push.c
index f173dcd64f..c93e781c3b 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2277,6 +2277,7 @@ int main(int argc, char **argv)
signal(SIGINT, remove_locks_on_signal);
signal(SIGHUP, remove_locks_on_signal);
signal(SIGQUIT, remove_locks_on_signal);
+ signal(SIGTERM, remove_locks_on_signal);
/* Check whether the remote has server info files */
remote->can_update_info_refs = 0;
diff --git a/lockfile.c b/lockfile.c
index cfc7335347..4023797b00 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -135,6 +135,9 @@ static int lock_file(struct lock_file *lk, const char *path)
if (0 <= lk->fd) {
if (!lock_file_list) {
signal(SIGINT, remove_lock_file_on_signal);
+ signal(SIGHUP, remove_lock_file_on_signal);
+ signal(SIGTERM, remove_lock_file_on_signal);
+ signal(SIGQUIT, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
lk->owner = getpid();
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 3531a992a9..46ec1ce8aa 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -212,4 +212,18 @@ test_expect_success 'do not fire editor in the presence of conflicts' '
test "`cat .git/result`" = "editor not started"
'
+pwd=`pwd`
+cat > .git/FAKE_EDITOR << EOF
+#! /bin/sh
+# kill -TERM command added below.
+EOF
+
+test_expect_success 'a SIGTERM should break locks' '
+ echo >>negative &&
+ sh -c '\''
+ echo kill -TERM $$ >> .git/FAKE_EDITOR
+ GIT_EDITOR=.git/FAKE_EDITOR exec git commit -a'\'' && exit 1 # should fail
+ ! test -f .git/index.lock
+'
+
test_done