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

Re: [PATCH v3 3/4] daemon: use sigaction() to install child_handler()

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2025, 15:33 UTC
Message-ID
<xmqqy0teplfa.fsf@gitster.g>
In-Reply-To
<d7c86948-e0b0-4864-88f8-fd1222e0dffe@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 34 quoted lines
> Only because you have chosen to use SA_RESTART here. I think it would
> be better to drop that and instead say something like
>
>
> POSIX leaves several aspects of the behavior of signal() up to the
> implementer. It is unspecified whether long running syscalls are
> restarted after an interrupt is received.  The event loop in "git
> daemon" assumes that poll() will return with EINTR if a child exits
> while it is polling but if poll() is restarted after an interrupt is
> received that does not happen which can lead to a build up of
> uncollected zombie processes.
>
> It is also unspecified whether the handler is reset after an interrupt
> is received. In order to work correctly on operating systems such as
> Solaris where the handler for SIGCLD is reset when a signal is
> received "git daemon" calls signal() from the SIGCLD handler to
> re-establish a handler for that signal. Unfortunately this causes
> infinite recursion on other operating systems such as AIX.
>
> Both of these problems can be addressed by using sigaction() instead
> of signal() which has much stricter semantics and so, by setting the
> appropriate flags, we can rely on poll() being interrupted and the
> SIGCLD handler not being reset. This change means that all long
> running system calls could fail with EINTR not just pall() but rest of
> the event loop code is designed to gracefully handle that.
>
> After this change there is still a race where a child that exits after
> it has been checked in check_dead_children() but before we call poll()
> will not be collected until a new connection is received or a child
> exits while we're polling. We could fix this by using the "self-pipe
> trick" but do not because ....
>
>
> Then we can drop patches 1 and 4.

Thanks for a suggestion. I really like the "everybody in these code paths are prepared to receive and handle EINTR just fine, so we do not have to do the SA_RESTART" observation very much.

Previous: Phillip WoodNext: Carlo Marcelo Arenas Belón
Message 54 of 70 in “daemon: explicitly allow EINTR during poll()”
  1. 0/3 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 24, 2025
  2. 1/3 compat/posix.h: track SA_RESTART fallbackCarlo Marcelo Arenas Belón via GitGitGadget, Jun 24, 2025
  3. Junio C HamanoJun 24, 2025
  4. Junio C HamanoJun 24, 2025
  5. 2/3 daemon: use sigaction() to install child_handler()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 24, 2025
  6. Junio C HamanoJun 24, 2025
  7. Carlo Marcelo Arenas BelónJun 24, 2025
  8. Chris TorekJun 24, 2025
  9. Junio C HamanoJun 24, 2025
  10. Carlo Marcelo Arenas BelónJun 24, 2025
  11. Junio C HamanoJun 24, 2025
  12. 3/3 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 24, 2025
  13. Carlo Marcelo Arenas BelónJun 24, 2025
  14. Junio C HamanoJun 24, 2025
  15. 0/3 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 25, 2025
  16. 1/3 compat/posix.h: track SA_RESTART fallbackCarlo Marcelo Arenas Belón via GitGitGadget, Jun 25, 2025
  17. Junio C HamanoJun 25, 2025
  18. Carlo Marcelo Arenas BelónJun 25, 2025
  19. Junio C HamanoJun 26, 2025
  20. Carlo Marcelo Arenas BelónJun 26, 2025
  21. Junio C HamanoJun 26, 2025
  22. 2/3 daemon: use sigaction() to install child_handler()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 25, 2025
  23. Junio C HamanoJun 25, 2025
  24. Junio C HamanoJun 25, 2025
  25. 3/3 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 25, 2025
  26. Junio C HamanoJun 25, 2025
  27. Phillip WoodJun 25, 2025
  28. Junio C HamanoJun 25, 2025
  29. Phillip WoodJun 25, 2025
  30. daemon: add a self pipe to trigger reaping of childrenCarlo Marcelo Arenas Belón, Jun 26, 2025
  31. 0/2 daemon: tracking childs without signalsCarlo Marcelo Arenas Belón, Jun 26, 2025
  32. 1/2 run-command: add a pipe() write end to childsCarlo Marcelo Arenas Belón, Jun 26, 2025
  33. 2/2 daemon: poor man's pidfd like POCCarlo Marcelo Arenas Belón, Jun 26, 2025
  34. Phillip WoodJun 27, 2025
  35. Carlo Marcelo Arenas BelónJun 28, 2025
  36. Phillip WoodJul 1, 2025
  37. Junio C HamanoJun 30, 2025
  38. Junio C HamanoJun 25, 2025
  39. Carlo Marcelo Arenas BelónJun 26, 2025
  40. 0/4 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 26, 2025
  41. 1/4 compat/posix.h: track SA_RESTART fallbackCarlo Marcelo Arenas Belón via GitGitGadget, Jun 26, 2025
  42. Junio C HamanoJun 27, 2025
  43. 2/4 compat/mingw: allow sigaction(SIGCHLD)Carlo Marcelo Arenas Belón via GitGitGadget, Jun 26, 2025
  44. Phillip WoodJun 26, 2025
  45. Carlo Marcelo Arenas BelónJun 26, 2025
  46. Phillip WoodJun 26, 2025
  47. Carlo Marcelo Arenas BelónJun 26, 2025
  48. phillip.wood123@gmail.comJun 26, 2025
  49. Carlo Marcelo Arenas BelónJun 26, 2025
  50. Phillip WoodJul 9, 2025
  51. Carlo Marcelo Arenas BelónJul 9, 2025
  52. 3/4 daemon: use sigaction() to install child_handler()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 26, 2025
  53. Phillip WoodJun 26, 2025
  54. Junio C HamanoJun 26, 2025
  55. Carlo Marcelo Arenas BelónJun 26, 2025
  56. Phillip WoodJun 26, 2025
  57. Junio C HamanoJul 7, 2025
  58. 4/4 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jun 26, 2025
  59. Phillip WoodJun 26, 2025
  60. Phillip WoodJul 9, 2025
  61. Carlo Marcelo Arenas BelónJul 9, 2025
  62. 0/2 daemon: explicitly allow EINTR during poll()Carlo Marcelo Arenas Belón via GitGitGadget, Jul 10, 2025
  63. 1/2 compat/mingw: allow sigaction(SIGCHLD)Carlo Marcelo Arenas Belón via GitGitGadget, Jul 10, 2025
  64. Eric SunshineJul 10, 2025
  65. 2/2 daemon: use sigaction() to install child_handler()Carlo Marcelo Arenas Belón via GitGitGadget, Jul 10, 2025
  66. Junio C HamanoJul 10, 2025
  67. Carlo ArenasJul 10, 2025
  68. Phillip WoodJul 11, 2025
  69. Junio C HamanoJul 14, 2025
  70. Phillip WoodJul 15, 2025

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.