runparts: simplify and adjust log levels

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-09-10 13:16:09 +02:00
parent c03176c42a
commit e9f403bceb
+7 -5
View File
@@ -109,15 +109,16 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
pid_t pid = 0;
int status;
/* cannot rely on d_type, not supported on all filesystems */
paste(path, sizeof(path), dir, name);
if (stat(path, &st)) {
dbg("Failed stat(%s): %s", path, strerror(errno));
warn("failed stat(%s)", path);
continue;
}
/* skip non-executable files and directories */
if (!S_ISEXEC(st.st_mode) || S_ISDIR(st.st_mode)) {
if (strcmp(name, ".") && strcmp(name, ".."))
dbg("Skipping %s ...", path);
dbg("skipping %s not an executable or is a directory", path);
continue;
}
@@ -134,7 +135,8 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
}
if (progress)
print_desc("Calling ", path);
print_desc("Calling", path);
pid = fork();
if (!pid) {
sig_unblock();
@@ -149,7 +151,7 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
} else {
if (WIFEXITED(status)) {
result = WEXITSTATUS(status);
warnx("%s exited with status %d", path, result);
dbg("%s exited with status %d", path, result);
} else if (WIFSIGNALED(status)) {
warnx("%s terminated by signal %d", path, WTERMSIG(status));
result = 1;