seatd-launch: propagate child exit status

When the child process exits with a non-zero code or is killed,
return with a non-zero code as well.
This commit is contained in:
Simon Ser 2021-08-06 08:23:01 +00:00 committed by Kenny Levinsen
parent 7d06b34ee2
commit f2a614dcd3

View file

@ -101,8 +101,9 @@ int main(int argc, char *argv[]) {
goto error_seatd; goto error_seatd;
} }
int status = 0;
while (true) { while (true) {
pid_t p = waitpid(child, NULL, 0); pid_t p = waitpid(child, &status, 0);
if (p == child) { if (p == child) {
break; break;
} else if (p == -1 && errno != EINTR) { } else if (p == -1 && errno != EINTR) {
@ -113,7 +114,12 @@ int main(int argc, char *argv[]) {
unlink(sockbuf); unlink(sockbuf);
kill(seatd_child, SIGTERM); kill(seatd_child, SIGTERM);
return 0;
if (WIFEXITED(status)) {
return WEXITSTATUS(status);
} else {
return 1;
}
error_seatd: error_seatd:
unlink(sockbuf); unlink(sockbuf);