@matheusbsbs / matheus-bagliano / commits / ad5fa3cc0e
Fork 0

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>

Paolo Bonzini committed May 29, 2008 at 16:55 UTC ad5fa3cc0e115a8b111868af2f727322feb144cb
3 files changed +18
http-push.c
+1
@@ -2277,6 +2277,7 @@ int main(int argc, char **argv)
2277 signal(SIGINT, remove_locks_on_signal);
2278 signal(SIGHUP, remove_locks_on_signal);
2279 signal(SIGQUIT, remove_locks_on_signal);
2280 + signal(SIGTERM, remove_locks_on_signal);
2281
2282 /* Check whether the remote has server info files */
2283 remote->can_update_info_refs = 0;
lockfile.c
+3
@@ -135,6 +135,9 @@ static int lock_file(struct lock_file *lk, const char *path)
135 if (0 <= lk->fd) {
136 if (!lock_file_list) {
137 signal(SIGINT, remove_lock_file_on_signal);
138 + signal(SIGHUP, remove_lock_file_on_signal);
139 + signal(SIGTERM, remove_lock_file_on_signal);
140 + signal(SIGQUIT, remove_lock_file_on_signal);
141 atexit(remove_lock_file);
142 }
143 lk->owner = getpid();
t/t7502-commit.sh
+14
@@ -212,4 +212,18 @@ test_expect_success 'do not fire editor in the presence of conflicts' '
212 test "`cat .git/result`" = "editor not started"
213 '
214
215 +pwd=`pwd`
216 +cat > .git/FAKE_EDITOR << EOF
217 +#! /bin/sh
218 +# kill -TERM command added below.
219 +EOF
220 +
221 +test_expect_success 'a SIGTERM should break locks' '
222 + echo >>negative &&
223 + sh -c '\''
224 + echo kill -TERM $$ >> .git/FAKE_EDITOR
225 + GIT_EDITOR=.git/FAKE_EDITOR exec git commit -a'\'' && exit 1 # should fail
226 + ! test -f .git/index.lock
227 +'
228 +
229 test_done