mirror of
https://github.com/troglobit/finit.git
synced 2026-11-10 16:31:21 +00:00
Fix #127: communicate run-parts progress/status
Printing the progress of run-parts script just like for `rc.local` seems reasonable. Also log a warning if any script exits abnormally. Signed-off-by: Jacques de Laval <jacques@de-laval.se>
This commit is contained in:
1 parent
fe969b64a0
commit
0557c83d40
1 file changed
+10
-1
+10
-1
@@ -451,6 +451,8 @@ int run_parts(char *dir, char *cmd)
|
|||||||
};
|
};
|
||||||
char *name = e[i]->d_name;
|
char *name = e[i]->d_name;
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
int status;
|
||||||
|
int exit_status;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s/%s", dir, name);
|
snprintf(path, sizeof(path), "%s/%s", dir, name);
|
||||||
if (stat(path, &st)) {
|
if (stat(path, &st)) {
|
||||||
@@ -475,13 +477,20 @@ int run_parts(char *dir, char *cmd)
|
|||||||
strlcat(path, cmd, sizeof(path));
|
strlcat(path, cmd, sizeof(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_desc("Calling ", path);
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
sig_unblock();
|
sig_unblock();
|
||||||
return execvp(_PATH_BSHELL, argv);
|
return execvp(_PATH_BSHELL, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
complete(path, pid);
|
status = complete(path, pid);
|
||||||
|
exit_status = WEXITSTATUS(status);
|
||||||
|
if (WIFEXITED(status) && exit_status)
|
||||||
|
_w("%s exited with status %d", path, exit_status);
|
||||||
|
else if (WIFSIGNALED(status))
|
||||||
|
_w("%s terminated by signad %d", path, WTERMSIG(status));
|
||||||
|
print_result(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num--)
|
while (num--)
|
||||||
|
|||||||
Reference in new issue
Block a user