diff mbox

[LEDE-DEV] uloop: make SIGCHLD signal handling optional

Message ID 20170703113756.6174-1-petar.paradzik@sartura.hr
State Changes Requested
Delegated to: Felix Fietkau
Headers show

Commit Message

Petar Paradzik July 3, 2017, 11:37 a.m. UTC
Some programs want to manage their own child life cycle without using
SIGCHLD signal handler. In these cases, uloop is reaping children for
them because they don't have SIGCHLD handler set. This patch makes it
possible to disable reaping children through 'uloop_handle_sigchld'
variable.

Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
---
 uloop.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Felix Fietkau Sept. 29, 2017, 10:41 a.m. UTC | #1
On 2017-07-03 13:37, Petar Paradzik wrote:
> Some programs want to manage their own child life cycle without using
> SIGCHLD signal handler. In these cases, uloop is reaping children for
> them because they don't have SIGCHLD handler set. This patch makes it
> possible to disable reaping children through 'uloop_handle_sigchld'
> variable.
> 
> Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
> ---
>  uloop.c | 5 ++++-
You also need to add 'extern bool uloop_handle_sigchld' to uloop.h

- Felix
Petar Paradzik Sept. 29, 2017, 11:35 a.m. UTC | #2
It is already present (in the master), but not used.

Regards,
Petar

On Fri, Sep 29, 2017 at 12:41 PM, Felix Fietkau <nbd@nbd.name> wrote:
> On 2017-07-03 13:37, Petar Paradzik wrote:
>> Some programs want to manage their own child life cycle without using
>> SIGCHLD signal handler. In these cases, uloop is reaping children for
>> them because they don't have SIGCHLD handler set. This patch makes it
>> possible to disable reaping children through 'uloop_handle_sigchld'
>> variable.
>>
>> Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
>> ---
>>  uloop.c | 5 ++++-
> You also need to add 'extern bool uloop_handle_sigchld' to uloop.h
>
> - Felix
Felix Fietkau Sept. 29, 2017, 11:37 a.m. UTC | #3
On 2017-09-29 13:35, Petar Paradzik wrote:
> It is already present (in the master), but not used.
You're right. Will merge this patch.

Thanks,

- Felix
diff mbox

Patch

diff --git a/uloop.c b/uloop.c
index d2f41bb..c43082b 100644
--- a/uloop.c
+++ b/uloop.c
@@ -58,6 +58,7 @@  static struct list_head processes = LIST_HEAD_INIT(processes);
 
 static int poll_fd = -1;
 bool uloop_cancelled = false;
+bool uloop_handle_sigchld = true;
 static int uloop_status = 0;
 static bool do_sigchld = false;
 
@@ -462,7 +463,9 @@  static void uloop_setup_signals(bool add)
 
 	uloop_install_handler(SIGINT, uloop_handle_sigint, &old_sigint, add);
 	uloop_install_handler(SIGTERM, uloop_handle_sigint, &old_sigterm, add);
-	uloop_install_handler(SIGCHLD, uloop_sigchld, &old_sigchld, add);
+
+	if (uloop_handle_sigchld)
+		uloop_install_handler(SIGCHLD, uloop_sigchld, &old_sigchld, add);
 
 	uloop_ignore_signal(SIGPIPE, add);
 }