summaryrefslogtreecommitdiffstats
path: root/aports-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'aports-cache.c')
-rw-r--r--aports-cache.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/aports-cache.c b/aports-cache.c
index 2132c70..8abfc96 100644
--- a/aports-cache.c
+++ b/aports-cache.c
@@ -197,6 +197,7 @@ int aports_cache_refresh(int dirfd, const char *cachefile, char *const shell_arg
{
pid_t shell_pid;
int shellfd, outfd = -1;
+ int status;
if (cachefile) {
outfd = open(cachefile, O_WRONLY | O_CREAT, 0660);
@@ -207,12 +208,19 @@ int aports_cache_refresh(int dirfd, const char *cachefile, char *const shell_arg
}
shellfd = spawn_shell_pipe(shell_argv, &shell_pid, outfd);
+ debug_printf("shell pid: %d\n", shell_pid);
- cache_refresh_or_check(dirfd, cachefile, shellfd);
- write(shellfd, "exit\n", 5);
- wait(NULL);
if (outfd >= 0)
close(outfd);
- return 0;
+
+ cache_refresh_or_check(dirfd, cachefile, shellfd);
+ write(shellfd, "exit 0\n", 7);
+
+ if (waitpid(shell_pid, &status, 0) < 0) {
+ warn("waitpid");
+ return -1;
+ }
+
+ return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
}