refactor signal handling for cleanup functions

The current code is very inconsistent about which signals
are caught for doing cleanup of temporary files and lock
files. Some callsites checked only SIGINT, while others
checked a variety of death-dealing signals.

This patch factors out those signals to a single function,
and then calls it everywhere. For some sites, that means
this is a simple clean up. For others, it is an improvement
in that they will now properly clean themselves up after a
larger variety of signals.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King
2009-01-22 01:03:08 -05:00
committed by Junio C Hamano
parent 4a16d07272
commit 57b235a4bc
8 changed files with 17 additions and 13 deletions

View File

@ -2262,10 +2262,7 @@ int main(int argc, char **argv)
goto cleanup;
}
sigchain_push(SIGINT, remove_locks_on_signal);
sigchain_push(SIGHUP, remove_locks_on_signal);
sigchain_push(SIGQUIT, remove_locks_on_signal);
sigchain_push(SIGTERM, remove_locks_on_signal);
sigchain_push_common(remove_locks_on_signal);
/* Check whether the remote has server info files */
remote->can_update_info_refs = 0;