Allow diff and index commands to be interrupted
authorPetr Baudis <pasky@suse.cz>
Tue, 31 Jan 2006 23:40:33 +0000 (00:40 +0100)
committerJunio C Hamano <junkio@cox.net>
Thu, 2 Feb 2006 03:47:52 +0000 (19:47 -0800)
So far, e.g. git-update-index --refresh was basically uninterruptable
by ctrl-c, since it hooked the SIGINT handler, but that handler would
only unlink the lockfile but not actually quit. This makes it propagate
the signal to the default handler.

Note that I expected it to work without resetting the signal handler to
SIG_DFL, but without that it ended in an infinite loop of tgkill()s -
is my glibc violating SUS or what?

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c
index.c

diff --git a/diff.c b/diff.c
index 8ae6dbc64e3c6c96e37755644d14998dc6e44a5a..ec51e7dd1832013cda561fa803668b1f2213c96a 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -555,6 +555,8 @@ static void remove_tempfile(void)
 static void remove_tempfile_on_signal(int signo)
 {
        remove_tempfile();
+       signal(SIGINT, SIG_DFL);
+       raise(signo);
 }
 
 /* An external diff command takes:
diff --git a/index.c b/index.c
index ad0eafedc288f2cf6b0d7c2493495087451ef466..f92b960ae46b2d43b2f46693fe086a4c4dbe3737 100644 (file)
--- a/index.c
+++ b/index.c
@@ -18,6 +18,8 @@ static void remove_lock_file(void)
 static void remove_lock_file_on_signal(int signo)
 {
        remove_lock_file();
+       signal(SIGINT, SIG_DFL);
+       raise(signo);
 }
 
 int hold_index_file_for_update(struct cache_file *cf, const char *path)