diff --git a/cronie.spec b/cronie.spec index e422e1b..fc4df93 100644 --- a/cronie.spec +++ b/cronie.spec @@ -11,6 +11,9 @@ License: GPL-2.0-or-later AND BSD-3-Clause AND BSD-2-Clause AND ISC AND LGPL-2 URL: https://github.com/cronie-crond/cronie Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz +# https://github.com/cronie-crond/cronie/pull/163 +Patch: n_option_wait_on_finnishing_grandchild_process.patch + Requires: dailyjobs %if %{with selinux} diff --git a/n_option_wait_on_finnishing_grandchild_process.patch b/n_option_wait_on_finnishing_grandchild_process.patch new file mode 100644 index 0000000..b01c6f5 --- /dev/null +++ b/n_option_wait_on_finnishing_grandchild_process.patch @@ -0,0 +1,25 @@ +From 5cf85f8cbb816ff1df5b317d6f8559b67e1993dd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= +Date: Wed, 25 Oct 2023 10:58:46 +0200 +Subject: [PATCH] -n option: wait on finnishing grandchild process + +With `WNOHANG` we skip sending the email when waitpid() returns 0, +which happens if the process is still running. Instead, using `0` +parameter will wait for the process to actually stop running. +--- + src/do_command.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/do_command.c b/src/do_command.c +index d7ca840..2ada913 100644 +--- a/src/do_command.c ++++ b/src/do_command.c +@@ -579,7 +579,7 @@ static int child_process(entry * e, char **jobenv) { + if (mail && e->flags & MAIL_WHEN_ERR) { + int jobstatus = -1; + if (jobpid > 0) { +- while (waitpid(jobpid, &jobstatus, WNOHANG) == -1) { ++ while (waitpid(jobpid, &jobstatus, 0) == -1) { + if (errno == EINTR) continue; + log_it("CRON", getpid(), "error", "invalid job pid", errno); + break;