tExit if REPO_EXEC fails to run - pm - barely a pack manager
(HTM) git clone git://z3bra.org/pm
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 719fc796cedbdd1b2db385d7a6235370d2d21abc
(DIR) parent db07b233b50ef3e66363489c8f85cd189525a579
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Fri, 16 Dec 2016 02:27:06 +0100
Exit if REPO_EXEC fails to run
Diffstat:
M pm.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/pm.c b/pm.c
t@@ -9,6 +9,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include <archive.h>
#include <archive_entry.h>
t@@ -797,7 +798,7 @@ install(const char *rootfs, const char *datadir, char *name)
int
pack_find(char *name, char *out)
{
- int fd[2];
+ int fd[2], status;
size_t len = 0;
pipe(fd);
t@@ -808,9 +809,14 @@ pack_find(char *name, char *out)
execlp(REPO_EXEC, REPO_EXEC, name, NULL);
}
+ close(fd[1]);
+
+ wait(&status);
+ if (status)
+ exit(1);
+
len = read(fd[0], out, PATH_MAX);
close(fd[0]);
- close(fd[1]);
if (len < 1)
return -1;