From: Volker Lendecke Date: Fri, 23 Apr 2021 09:17:33 +0000 (+0200) Subject: printing: Avoid zombies in the background daemon X-Git-Tag: tevent-0.11.0~1030 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8d2eb62a1070dc2ee5be99338d4fa66981002c12;p=thirdparty%2Fsamba.git printing: Avoid zombies in the background daemon Whatever you read about waitpid() tells you should should run it in a loop. Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c index 7d7d53c35d0..152b5b645ce 100644 --- a/source3/printing/queue_process.c +++ b/source3/printing/queue_process.c @@ -264,14 +264,20 @@ static void bq_sig_chld_handler(struct tevent_context *ev_ctx, int status; pid_t pid; - pid = waitpid(-1, &status, WNOHANG); - if (WIFEXITED(status)) { - DEBUG(6, ("Bq child process %d terminated with %d\n", - (int)pid, WEXITSTATUS(status))); - } else { - DEBUG(3, ("Bq child process %d terminated abnormally\n", - (int)pid)); - } + do { + do { + pid = waitpid(-1, &status, WNOHANG); + } while ((pid == -1) && (errno == EINTR)); + + if (WIFEXITED(status)) { + DBG_INFO("Bq child process %d terminated with %d\n", + (int)pid, + WEXITSTATUS(status)); + } else { + DBG_NOTICE("Bq child process %d terminated abnormally\n", + (int)pid); + } + } while (pid > 0); } static void bq_setup_sig_chld_handler(struct tevent_context *ev_ctx)