path: root/lockfile.c
diff options
authorJeff King <>2009-01-22 06:03:08 (GMT)
committerJunio C Hamano <>2009-01-22 06:46:53 (GMT)
commit57b235a4bc8884a57c6f863605a54b7bfceb0997 (patch)
tree7128eed3ea8f2352f3b43e810d9edce740f920e8 /lockfile.c
parent4a16d072723b48699ea162da24eff05eba298834 (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'lockfile.c')
1 files changed, 1 insertions, 5 deletions
diff --git a/lockfile.c b/lockfile.c
index 3cd57dc..021c337 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -137,11 +137,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)
lk->fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
if (0 <= lk->fd) {
if (!lock_file_list) {
- sigchain_push(SIGINT, remove_lock_file_on_signal);
- sigchain_push(SIGHUP, remove_lock_file_on_signal);
- sigchain_push(SIGTERM, remove_lock_file_on_signal);
- sigchain_push(SIGQUIT, remove_lock_file_on_signal);
- sigchain_push(SIGPIPE, remove_lock_file_on_signal);
+ sigchain_push_common(remove_lock_file_on_signal);
lk->owner = getpid();