{"thread":{"id":"3203","subject":"[PATCH] Allow diff and index commands to be interrupted","startedAt":"2006-01-31T23:40:33Z","lastAt":"2006-01-31T23:40:33Z","messageCount":1,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"15347","messageId":"20060131234033.16288.34502.stgit@machine.or.cz","threadId":"3203","inReplyTo":null,"subject":"[PATCH] Allow diff and index commands to be interrupted","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-01-31T23:40:33Z","receivedAt":"2006-01-31T23:40:33Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"So far, e.g. git-update-index --refresh was basically uninterruptable\nby ctrl-c, since it hooked the SIGINT handler, but that handler would\nonly unlink the lockfile but not actually quit. This makes it propagate\nthe signal to the default handler.\n\nNote that I expected it to work without resetting the signal handler to\nSIG_DFL, but without that it ended in an infinite loop of tgkill()s -\nis my glibc violating SUS or what?\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n diff.c  |    2 ++\n index.c |    2 ++\n 2 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8ae6dbc..ec51e7d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -555,6 +555,8 @@ static void remove_tempfile(void)\n static void remove_tempfile_on_signal(int signo)\n {\n \tremove_tempfile();\n+\tsignal(SIGINT, SIG_DFL);\n+\traise(signo);\n }\n \n /* An external diff command takes:\ndiff --git a/index.c b/index.c\nindex ad0eafe..f92b960 100644\n--- a/index.c\n+++ b/index.c\n@@ -18,6 +18,8 @@ static void remove_lock_file(void)\n static void remove_lock_file_on_signal(int signo)\n {\n \tremove_lock_file();\n+\tsignal(SIGINT, SIG_DFL);\n+\traise(signo);\n }\n \n int hold_index_file_for_update(struct cache_file *cf, const char *path)\n"}]}