From 9a51d6cb851306c694c2b7588ccf8d878584bee2 Mon Sep 17 00:00:00 2001 From: Anjali Nijhara Date: Thu, 14 Dec 2023 14:09:21 +0530 Subject: [PATCH] Modify run_notify func to wait for terminating child process Change-Id: Iec382fb152dcbcd3bf5511ce19c4235679365c75 --- toys/pending/dhcpd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/toys/pending/dhcpd.c b/toys/pending/dhcpd.c index 9f1f9ad..3bac14d 100644 --- a/toys/pending/dhcpd.c +++ b/toys/pending/dhcpd.c @@ -1186,6 +1186,8 @@ static void run_notify(char **argv) struct stat sts; volatile int error = 0; pid_t pid; + int rv = 0; + dbg("run_notify"); if (stat(argv[0], &sts) == -1 && errno == ENOENT) { infomsg(infomode, "notify file: %s : not exist.", argv[0]); @@ -1203,11 +1205,9 @@ static void run_notify(char **argv) error = errno; _exit(111); } - if (error) { - waitpid(pid, NULL, 0); - errno = error; - } - dbg("script complete.\n"); + waitpid(pid, &rv, 0); + errno = error; + dbg("wait pid (%u) rv (%d)", pid, rv); } static void write_leasefile(void) -- 2.7.4