summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a16d07)
raw | patch | inline | side by side (parent: 4a16d07)
author | Jeff King <peff@peff.net> | |
Thu, 22 Jan 2009 06:03:08 +0000 (01:03 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 22 Jan 2009 06:46:53 +0000 (22:46 -0800) |
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>
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>
builtin-clone.c | patch | blob | history | |
builtin-fetch--tool.c | patch | blob | history | |
builtin-fetch.c | patch | blob | history | |
diff.c | patch | blob | history | |
http-push.c | patch | blob | history | |
lockfile.c | patch | blob | history | |
sigchain.c | patch | blob | history | |
sigchain.h | patch | blob | history |
diff --git a/builtin-clone.c b/builtin-clone.c
index 18b9392334a0931076855b175ab368deea8ac122..44c80734b70b13780cbb48b0566bf99e2233f2a8 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
}
junk_git_dir = git_dir;
atexit(remove_junk);
- sigchain_push(SIGINT, remove_junk_on_signal);
+ sigchain_push_common(remove_junk_on_signal);
setenv(CONFIG_ENVIRONMENT, xstrdup(mkpath("%s/config", git_dir)), 1);
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index b1d7f8fb32fd2d2ee6cfd18ed310a5d70e9e5ceb..29356d25db910c6d90df46da87aa374467611350 100644 (file)
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
char buffer[1024];
int err = 0;
- sigchain_push(SIGINT, remove_keep_on_signal);
+ sigchain_push_common(remove_keep_on_signal);
atexit(remove_keep);
while (fgets(buffer, sizeof(buffer), stdin)) {
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 8c86974cbee0341d7c0e110055bb4347ad5908ad..1e4a3d9c516c88d701819b7f4b73c722412d540f 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
ref_nr = j;
}
- sigchain_push(SIGINT, unlock_pack_on_signal);
+ sigchain_push_common(unlock_pack_on_signal);
atexit(unlock_pack);
exit_code = do_fetch(transport,
parse_fetch_refspec(ref_nr, refs), ref_nr);
index 9c9977d892e475b0fa98a946393118ef59d73100..8ce898a6b09f7ad013c285ba46bdf6922fbe9bc5 100644 (file)
--- a/diff.c
+++ b/diff.c
if (!remove_tempfile_installed) {
atexit(remove_tempfile);
- sigchain_push(SIGINT, remove_tempfile_on_signal);
+ sigchain_push_common(remove_tempfile_on_signal);
remove_tempfile_installed = 1;
}
diff --git a/http-push.c b/http-push.c
index dec395deed0778b707b62e86a35086f6e6b73a72..7d5c23edc4b864958671a26bde64ce21e54924bc 100644 (file)
--- a/http-push.c
+++ b/http-push.c
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;
diff --git a/lockfile.c b/lockfile.c
index 3cd57dc3854c22b071619e03c3ccd26981b0c45b..021c3375c10711027269ee58bb9a201bc69c519a 100644 (file)
--- a/lockfile.c
+++ b/lockfile.c
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);
atexit(remove_lock_file);
}
lk->owner = getpid();
diff --git a/sigchain.c b/sigchain.c
index a18d505e56b2f80e3ecae00afdfa05f9b87dc119..1118b99e57d3308f333c56f487329a8fef75a7df 100644 (file)
--- a/sigchain.c
+++ b/sigchain.c
s->n--;
return 0;
}
+
+void sigchain_push_common(sigchain_fun f)
+{
+ sigchain_push(SIGINT, f);
+ sigchain_push(SIGHUP, f);
+ sigchain_push(SIGTERM, f);
+ sigchain_push(SIGQUIT, f);
+ sigchain_push(SIGPIPE, f);
+}
diff --git a/sigchain.h b/sigchain.h
index 254ebb0fa69fc759e73de431721357209f72180d..618083bce0c66a551fd4d894b31520a67b25bac9 100644 (file)
--- a/sigchain.h
+++ b/sigchain.h
int sigchain_push(int sig, sigchain_fun f);
int sigchain_pop(int sig);
+void sigchain_push_common(sigchain_fun f);
+
#endif /* SIGCHAIN_H */