process-util: rework wait_for_terminate_and_warn() to take a flags parameter

This renames wait_for_terminate_and_warn() to
wait_for_terminate_and_check(), and adds a flags parameter, that
controls how much to log: there's one flag that means we log about
abnormal stuff, and another one that controls whether we log about
non-zero exit codes. Finally, there's a shortcut flag value for logging
in both cases, as that's what we usually use.

All callers are accordingly updated. At three occasions duplicate logging
is removed, i.e. where the old function was called but logged in the
caller, too.
This commit is contained in:
Lennart Poettering
2018-01-04 13:27:27 +01:00
parent b6e1fff13d
commit 7d4904fe7a
18 changed files with 64 additions and 47 deletions
+5 -8
View File
@@ -147,7 +147,7 @@ static int do_execute(
return log_oom();
t = NULL;
} else {
r = wait_for_terminate_and_warn(t, pid, true);
r = wait_for_terminate_and_check(t, pid, WAIT_LOG);
if (r < 0)
continue;
@@ -177,7 +177,7 @@ static int do_execute(
t = hashmap_remove(pids, PID_TO_PTR(pid));
assert(t);
wait_for_terminate_and_warn(t, pid, true);
(void) wait_for_terminate_and_check(t, pid, WAIT_LOG);
}
return 0;
@@ -224,14 +224,11 @@ int execute_directories(
_exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}
r = wait_for_terminate_and_warn(name, executor_pid, true);
r = wait_for_terminate_and_check(name, executor_pid, WAIT_LOG);
if (r < 0)
return log_error_errno(r, "Execution failed: %m");
if (r > 0) {
/* non-zero return code from child */
log_error("Forker process failed.");
return r;
if (r > 0) /* non-zero return code from child */
return -EREMOTEIO;
}
if (!callbacks)
return 0;