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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Carlo Marcelo Arenas Belón via GitGitGadget"
<gitgitgadget@xxxxxxxxx> writes:

> From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@xxxxxxxxx>
>
> In a future change, the flags used for processing SIGCHLD will need to
> be updated, which is only possible by using sigaction().
>
> Replace the call, which hs the added benefit of using BSD semantics
> reliably and therefore not needing the rearming call.

"hs" -> "has"

Hmph, if we do not have to rearm, do we even need to have the
handler at all, now it is a completely empty function?  Presumably
we'll see the answer to this question in the next step?

> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx>
> ---
>  daemon.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/daemon.c b/daemon.c
> index d1be61fd5789..d870ad2f63c1 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -917,9 +917,7 @@ static void child_handler(int signo UNUSED)
>  	/*
>  	 * Otherwise empty handler because systemcalls will get interrupted
>  	 * upon signal receipt
> -	 * SysV needs the handler to be rearmed
>  	 */
> -	signal(SIGCHLD, child_handler);
>  }
>  
>  static int set_reuse_addr(int sockfd)
> @@ -1121,6 +1119,7 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
>  static int service_loop(struct socketlist *socklist)
>  {
>  	struct pollfd *pfd;
> +	struct sigaction sa;
>  
>  	CALLOC_ARRAY(pfd, socklist->nr);
>  
> @@ -1129,7 +1128,10 @@ static int service_loop(struct socketlist *socklist)
>  		pfd[i].events = POLLIN;
>  	}
>  
> -	signal(SIGCHLD, child_handler);
> +	sigemptyset(&sa.sa_mask);
> +	sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
> +	sa.sa_handler = child_handler;
> +	sigaction(SIGCHLD, &sa, NULL);
>  
>  	for (;;) {
>  		check_dead_children();




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux