From 430cd0cf13ffda3d9850f7a17f25bed51233ad63 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 1 Feb 2021 03:56:32 +0100 Subject: Reap child in exec program async --- src/Program.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Program.cpp') diff --git a/src/Program.cpp b/src/Program.cpp index d9927af..33f5cd0 100644 --- a/src/Program.cpp +++ b/src/Program.cpp @@ -217,8 +217,6 @@ int exec_program_async(const char **args, pid_t *result_process_id) { setsid(); signal(SIGHUP, SIG_IGN); - // TODO: Still creates zombie??? find a fix! - // Daemonize child to make the parent the init process which will reap the zombie child pid_t second_child = fork(); if(second_child == 0) { // child @@ -232,6 +230,8 @@ int exec_program_async(const char **args, pid_t *result_process_id) { } else { /* parent */ if(result_process_id) *result_process_id = pid; + + waitpid(pid, nullptr, 0); } return 0; } -- cgit v1.2.3