Re: [PATCH v2 3/3] daemon: explicitly allow EINTR during poll()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 25, 2025, 16:11 UTC
- Message-ID
- <xmqqzfdvx0lb.fsf@gitster.g>
- In-Reply-To
- <b737e0389dfc280994e118736bf4452ed80ebcd6.1750836928.git.gitgitgadget@gmail.com>
"Carlo Marcelo Arenas Belón via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 45 quoted lines
> From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@gmail.com>
>
> If the setup for the SIGCHLD signal handler sets SA_RESTART, poll()
> might not return with -1 and set errno to EINTR when a signal is
> received.
>
> Since the logic to reap zombie childs relies on those interruptions
> make sure to explicitly disable SA_RESTART around this function.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> daemon.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/daemon.c b/daemon.c
> index 8133bd902157..01337fcfedab 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -1133,6 +1133,15 @@ static void set_signal_handler(struct sigaction *psa)
> sigaction(SIGCHLD, psa, NULL);
> }
>
> +static void set_sa_restart(struct sigaction *psa, int enable)
> +{
> + if (enable)
> + psa->sa_flags |= SA_RESTART;
> + else
> + psa->sa_flags &= ~SA_RESTART;
> + sigaction(SIGCHLD, psa, NULL);
> +}
> +
> #else
>
> static void set_signal_handler(struct sigaction *psa UNUSED)
> @@ -1140,6 +1149,12 @@ static void set_signal_handler(struct sigaction *psa UNUSED)
> signal(SIGCHLD, child_handler);
> }
>
> +static void set_sa_restart(struct sigaction *psa UNUSED, int enable UNUSED)
> +{
> +}
> +
> +#endif
> +
> static int service_loop(struct socketlist *socklist)OK, this is the answer to the question I was puzzled with while reviewing the [2/3].