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

[PATCH v3 7/9] builtin/merge-index.c: replace signal() with sigaction()

From
Jeremiah Mahler <jmmahler@gmail.com>
Date
Jun 1, 2014, 18:10 UTC
Message-ID
<e74a8efbb3a967c785fc282e5c4033dade15ebfd.1401645403.git.jmmahler@gmail.com>
In-Reply-To
<cover.1401645403.git.jmmahler@gmail.com>
From the 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 builtin/merge-index.c
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
---
 builtin/merge-index.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index b416d92..25db374 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -68,11 +68,14 @@ static void merge_all(void)
 int cmd_merge_index(int argc, const char **argv, const char *prefix)
 {
 	int i, force_file = 0;
+	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, NULL);
 
 	if (argc < 3)
 		usage("git merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
-- 
2.0.0.8.g7bf6e1f.dirty
Previous: Jeremiah MahlerNext: Jeremiah Mahler
Message 9 of 15 in “replace signal() with sigaction()”
  1. 0/9 replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  2. 1/9 compat/mingw.c: expand MinGW support for sigactionJeremiah Mahler, Jun 1, 2014
  3. Johannes SixtJun 2, 2014
  4. 2/9 connect.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  5. 3/9 progress.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  6. 4/9 write_or_die.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  7. 5/9 daemon.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  8. 6/9 builtin/log.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  9. 7/9 builtin/merge-index.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  10. 8/9 builtin/verify-tag.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  11. 9/9 sigchain.c: replace signal() with sigaction()Jeremiah Mahler, Jun 1, 2014
  12. Johannes SixtJun 2, 2014
  13. Jeremiah MahlerJun 2, 2014
  14. Junio C HamanoJun 2, 2014
  15. Jeremiah MahlerJun 2, 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.