git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: RFC: [PATCH] ignore SIGINT&QUIT while waiting for external command

From
Jeff King <peff@peff.net>
Date
Oct 19, 2010, 13:40 UTC
Message-ID
<20101019134040.GA3956@sigill.intra.peff.net>
In-Reply-To
<20101019133236.GA804@sigill.intra.peff.net>
On Tue, Oct 19, 2010 at 09:32:36AM -0400, Jeff King wrote:
Show 12 quoted lines
> How does this interact with the sigchain code? If I do:
> 
>   start_command(...);
>   sigchain_push(...);
>   finish_command(...);
> 
> we will overwrite the function pushed in the sigchain_push with a stale
> handler. I think you could just replace your signal() calls with:
> 
>   sigchain_push(SIGINT, SIG_IGN);
>   ...
>   sigchain_pop(SIGINT);
Which, FWIW, would look like this:
diff --git a/run-command.c b/run-command.c
index 2a1041e..24e0f46 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "run-command.h"
 #include "exec_cmd.h"
+#include "sigchain.h"
 
 static inline void close_pair(int fd[2])
 {
@@ -102,6 +103,9 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
 	while ((waiting = waitpid(pid, &status, 0)) < 0 && errno == EINTR)
 		;	/* nothing */
 
+	sigchain_pop(SIGINT);
+	sigchain_pop(SIGQUIT);
+
 	if (waiting < 0) {
 		failed_errno = errno;
 		error("waitpid for %s failed: %s", argv0, strerror(errno));
@@ -202,8 +206,12 @@ fail_pipe:
 		notify_pipe[0] = notify_pipe[1] = -1;
 
 	fflush(NULL);
+	sigchain_push(SIGINT, SIG_IGN);
+	sigchain_push(SIGQUIT, SIG_IGN);
 	cmd->pid = fork();
 	if (!cmd->pid) {
+		sigchain_pop(SIGINT);
+		sigchain_pop(SIGQUIT);
 		/*
 		 * Redirect the channel to write syscall error messages to
 		 * before redirecting the process's stderr so that all die()
Previous: Jeff KingNext: Jonathan Nieder
Message 5 of 10 in “git subcommand sigint gotcha”
  1. Joey HessOct 19, 2010
  2. Dmitry PotapovOct 19, 2010
  3. RFC: [PATCH] ignore SIGINT&QUIT while waiting for external commandDmitry Potapov, Oct 19, 2010
  4. Jeff KingOct 19, 2010
  5. Jeff KingOct 19, 2010
  6. Jonathan NiederOct 19, 2010
  7. Jeff KingOct 19, 2010
  8. Jakub NarebskiOct 19, 2010
  9. Jonathan NiederOct 19, 2010
  10. Dmitry PotapovOct 19, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.