runparts: simplify and adjust log levels

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