Skip to content

Commit 1db0027

Browse files
committed
src/runtime.c: preserve exit status on --appimage-extract-and-run (normal exit)
Signed-off-by: Tim Janik <[email protected]>
1 parent 4f2a991 commit 1db0027

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/runtime.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,19 +671,22 @@ int main(int argc, char *argv[]) {
671671
exit(EXIT_EXECERROR);
672672
}
673673

674-
int rv = waitpid(pid, NULL, 0);
674+
int status = 0;
675+
int rv = waitpid(pid, &status, 0);
676+
status = rv > 0 && WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_EXECERROR;
675677

676678
if (getenv("NO_CLEANUP") == NULL) {
677679
if (!rm_recursive(prefix)) {
678680
fprintf(stderr, "Failed to clean up cache directory\n");
679-
rv = -1;
681+
if (status == 0) /* avoid messing existing failure exit status */
682+
status = EXIT_EXECERROR;
680683
}
681684
}
682685

683686
// template == prefix, must be freed only once
684687
free(prefix);
685688

686-
exit(rv >= 0 ? 0 : EXIT_EXECERROR);
689+
exit(status);
687690
}
688691

689692
if(arg && strcmp(arg,"appimage-version")==0) {

0 commit comments

Comments
 (0)