commit: aa2759830b766bd668279eda7124e26c339fee54
parent 1877c450642f2d69a3eb9e9107d5c568ab38557b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 11 Jan 2026 05:01:28 +0100
init.c: handle child process exit code
Diffstat:
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/init.c b/init.c
@@ -34,12 +34,25 @@ exec_wait(char *args[])
return -1;
}
- if(waitpid(child, NULL, 0) == -1)
+ int stat;
+ if(waitpid(child, &stat, 0) == -1)
{
fprintf(stderr, "Failed waiting for child of pid %d: %s\n", child, strerror(errno));
return -1;
}
+ if(!WIFEXITED(stat))
+ {
+ fprintf(stderr, "'%s' did not exit normally\n", args[0]);
+ return -1;
+ }
+
+ if(WEXITSTATUS(stat) != 0)
+ {
+ fprintf(stderr, "'%s' exited with code %d\n", args[0], WEXITSTATUS(stat));
+ return -1;
+ }
+
return 0;
}