Skip to contentSkip to conversation

Allow diff and index commands to be interrupted

PATCH New Petr Baudis 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow diff and index commands to be interrupted

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?

---

 diff.c  |    2 ++
 index.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)
diff.c +2 -0
index 8ae6dbc..ec51e7d 100644
@@ -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:
index.c +2 -0
index ad0eafe..f92b960 100644
@@ -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)