From 8afabc50908968a393e33b20a8a839c3daf307f1 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Tue, 13 Feb 2018 18:04:31 +0000 Subject: [PATCH] manager: avoid infinite loop for unexpected waitid() error (#8168) I think if we log the error as being _ignored_, we should also consider the event as handled and clear it. This was the behaviour prior to 575b300b (PR #7968). I don't think we particularly wanted to change behaviour and keep retrying. Sometimes that's useful, other times you cause more problems by filling the logs. Plus a nearby typo fix. --- src/core/manager.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index 5021e00b870..a2a3eea2f52 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2121,11 +2121,10 @@ static int manager_dispatch_sigchld(sd_event_source *source, void *userdata) { if (waitid(P_ALL, 0, &si, WEXITED|WNOHANG|WNOWAIT) < 0) { - if (errno == ECHILD) - goto turn_off; + if (errno != ECHILD) + log_error_errno(errno, "Failed to peek for child with waitid(), ignoring: %m"); - log_error_errno(errno, "Failed to peek for child with waitid(), ignoring: %m"); - return 0; + goto turn_off; } if (si.si_pid <= 0) @@ -2258,7 +2257,7 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t case SIGCHLD: r = sd_event_source_set_enabled(m->sigchld_event_source, SD_EVENT_ON); if (r < 0) - log_warning_errno(r, "Failed to enable SIGCHLD even source, ignoring: %m"); + log_warning_errno(r, "Failed to enable SIGCHLD event source, ignoring: %m"); break;