Subject: Re: [PATCH v2 3/3] daemon: explicitly allow EINTR during poll()

From: Junio C Hamano <[email-masked]>
Date: Wed, 25 Jun 2025 09:11:44 -0700

"Carlo Marcelo Arenas Belón via GitGitGadget"
<[email-masked]> writes:

> From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <[email-masked]>
>
> 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 <[email-masked]>
> ---
>  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].