mirror of
https://github.com/troglobit/finit.git
synced 2026-12-04 21:58:19 +00:00
Fix WIFEXITED() logic when collecting reaped processes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
3ce5a2a965
commit
be9d54561d
2 files changed
+8
-10
No files matched your search
+3
-5
@@ -484,7 +484,6 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
|
|||||||
};
|
};
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
int status;
|
int status;
|
||||||
int exit_status;
|
|
||||||
|
|
||||||
paste(path, sizeof(path), dir, name);
|
paste(path, sizeof(path), dir, name);
|
||||||
if (stat(path, &st)) {
|
if (stat(path, &st)) {
|
||||||
@@ -521,13 +520,12 @@ int run_parts(char *dir, char *cmd, const char *env[], int progress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = complete(path, pid);
|
status = complete(path, pid);
|
||||||
exit_status = WEXITSTATUS(status);
|
if (WIFEXITED(status))
|
||||||
if (WIFEXITED(status) && exit_status)
|
warnx("%s exited with status %d", path, WEXITSTATUS(status));
|
||||||
warnx("%s exited with status %d", path, exit_status);
|
|
||||||
else if (WIFSIGNALED(status))
|
else if (WIFSIGNALED(status))
|
||||||
warnx("%s terminated by signad %d", path, WTERMSIG(status));
|
warnx("%s terminated by signad %d", path, WTERMSIG(status));
|
||||||
if (progress)
|
if (progress)
|
||||||
print_result(status);
|
print_result(WEXITSTATUS(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (num--)
|
while (num--)
|
||||||
|
|||||||
+5
-5
@@ -818,11 +818,11 @@ static int service_start(svc_t *svc)
|
|||||||
case SVC_TYPE_RUN:
|
case SVC_TYPE_RUN:
|
||||||
svc->status = complete(svc->cmd, pid);
|
svc->status = complete(svc->cmd, pid);
|
||||||
dbg("collected %s(%d), normal exit: %d, signaled: %d, exit code: %d",
|
dbg("collected %s(%d), normal exit: %d, signaled: %d, exit code: %d",
|
||||||
svc_ident(svc, NULL, 0), pid, WIFEXITED(svc->status),
|
svc_ident(svc, NULL, 0), pid, WIFEXITED(svc->status),
|
||||||
WIFSIGNALED(svc->status), WEXITSTATUS(svc->status));
|
WIFSIGNALED(svc->status), WEXITSTATUS(svc->status));
|
||||||
if (WIFEXITED(svc->status) && !WEXITSTATUS(svc->status)) {
|
if (WIFEXITED(svc->status)) {
|
||||||
svc->started = 1;
|
svc->started = 1;
|
||||||
result = 0;
|
result = WEXITSTATUS(svc->status);
|
||||||
} else {
|
} else {
|
||||||
svc->started = 0;
|
svc->started = 0;
|
||||||
result = 1;
|
result = 1;
|
||||||
@@ -1858,7 +1858,7 @@ void service_monitor(pid_t lost, int status)
|
|||||||
service_cleanup(svc);
|
service_cleanup(svc);
|
||||||
} else if (svc_is_runtask(svc)) {
|
} else if (svc_is_runtask(svc)) {
|
||||||
/* run/task should run at least once per runlevel */
|
/* run/task should run at least once per runlevel */
|
||||||
if (WIFEXITED(status) && !WEXITSTATUS(status))
|
if (WIFEXITED(status))
|
||||||
svc->started = 1;
|
svc->started = 1;
|
||||||
else
|
else
|
||||||
svc->started = 0;
|
svc->started = 0;
|
||||||
@@ -2172,7 +2172,7 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
|
|||||||
|
|
||||||
/* create success/failure condition when entering SVC_DONE_STATE. */
|
/* create success/failure condition when entering SVC_DONE_STATE. */
|
||||||
if (*state == SVC_DONE_STATE) {
|
if (*state == SVC_DONE_STATE) {
|
||||||
if (svc->started)
|
if (svc->started && !WEXITSTATUS(svc->status))
|
||||||
cond_set_oneshot(success);
|
cond_set_oneshot(success);
|
||||||
else
|
else
|
||||||
cond_set_oneshot(failure);
|
cond_set_oneshot(failure);
|
||||||
|
|||||||
Reference in new issue
Block a user