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

[PATCH v2 2/2] connect.c: replace signal() with sigaction()

From
Jeremiah Mahler <jmmahler@gmail.com>
Date
May 30, 2014, 20:58 UTC
Message-ID
<1d11d5da7ebc3a6e0d4ab64802b601526c19113c.1401482787.git.jmmahler@gmail.com>
In-Reply-To
<cover.1401482787.git.jmmahler@gmail.com>
From signal(2) man page:
  The behavior of signal() varies across UNIX versions, and has also var‐
  ied historically across different versions of Linux.   Avoid  its  use:
  use sigaction(2) instead.
Replaced signal() with sigaction() in connect.c
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
---
 connect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/connect.c b/connect.c
index a983d06..b2a33c9 100644
--- a/connect.c
+++ b/connect.c
@@ -665,11 +665,14 @@ struct child_process *git_connect(int fd[2], const char *url,
 	enum protocol protocol;
 	const char **arg;
 	struct strbuf cmd = STRBUF_INIT;
+	struct sigaction sa;
 
 	/* Without this we cannot rely on waitpid() to tell
 	 * what happened to our children.
 	 */
-	signal(SIGCHLD, SIG_DFL);
+	memset(&sa, 0, sizeof(sa));
+	sa.sa_handler = SIG_DFL;
+	sigaction(SIGCHLD, &sa, 0);
 
 	protocol = parse_connect_url(url, &hostandport, &path);
 	if (flags & CONNECT_DIAG_URL) {
-- 
2.0.0.2.g1d11d5d
Previous: Jeremiah MahlerNext: Andreas Schwab
Message 3 of 6 in “replace signal() with sigaction()”
  1. 0/2 replace signal() with sigaction()Jeremiah Mahler, May 30, 2014
  2. 1/2 compat/mingw.c: expand MinGW support for sigactionJeremiah Mahler, May 30, 2014
  3. 2/2 connect.c: replace signal() with sigaction()Jeremiah Mahler, May 30, 2014
  4. Andreas SchwabMay 30, 2014
  5. Chris PackhamMay 31, 2014
  6. Jeremiah MahlerMay 31, 2014

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.