summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2017-04-16 08:36:32 -0400
committerAndrew Gregory <andrew.gregory.8@gmail.com>2017-04-16 19:41:35 -0400
commit3c013f68ac06d791830fd722b17bc771df47d436 (patch)
tree28cb1242bcfb1bb218ab062fe8589063c3ab1142 /lib
parentfae33a1faf3f94ea46049664ef483b2a3e0d3f01 (diff)
downloadpacman-3c013f68ac06d791830fd722b17bc771df47d436.tar.xz
run_chroot: label pipe endpoints for readability
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/util.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 5a7f2c87..35fc7f41 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -564,6 +564,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
int cwdfd;
int retval = 0;
+#define HEAD 1
+#define TAIL 0
+
/* save the cwd so we can restore it later */
OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC);
if(cwdfd < 0) {
@@ -608,13 +611,13 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
close(0);
close(1);
close(2);
- while(dup2(child2parent_pipefd[1], 1) == -1 && errno == EINTR);
- while(dup2(child2parent_pipefd[1], 2) == -1 && errno == EINTR);
- while(dup2(parent2child_pipefd[0], 0) == -1 && errno == EINTR);
- close(parent2child_pipefd[0]);
- close(parent2child_pipefd[1]);
- close(child2parent_pipefd[0]);
- close(child2parent_pipefd[1]);
+ while(dup2(child2parent_pipefd[HEAD], 1) == -1 && errno == EINTR);
+ while(dup2(child2parent_pipefd[HEAD], 2) == -1 && errno == EINTR);
+ while(dup2(parent2child_pipefd[TAIL], 0) == -1 && errno == EINTR);
+ close(parent2child_pipefd[TAIL]);
+ close(parent2child_pipefd[HEAD]);
+ close(child2parent_pipefd[TAIL]);
+ close(child2parent_pipefd[HEAD]);
if(cwdfd >= 0) {
close(cwdfd);
}
@@ -643,20 +646,20 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
nfds_t nfds = 2;
struct pollfd fds[2], *child2parent = &(fds[0]), *parent2child = &(fds[1]);
- child2parent->fd = child2parent_pipefd[0];
+ child2parent->fd = child2parent_pipefd[TAIL];
child2parent->events = POLLIN;
fcntl(child2parent->fd, F_SETFL, O_NONBLOCK);
- close(child2parent_pipefd[1]);
- close(parent2child_pipefd[0]);
+ close(child2parent_pipefd[HEAD]);
+ close(parent2child_pipefd[TAIL]);
if(stdin_cb) {
- parent2child->fd = parent2child_pipefd[1];
+ parent2child->fd = parent2child_pipefd[HEAD];
parent2child->events = POLLOUT;
fcntl(parent2child->fd, F_SETFL, O_NONBLOCK);
} else {
parent2child->fd = -1;
parent2child->events = 0;
- close(parent2child_pipefd[1]);
+ close(parent2child_pipefd[HEAD]);
}
#define STOP_POLLING(p) do { close(p->fd); p->fd = -1; } while(0)
@@ -691,6 +694,8 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
}
#undef STOP_POLLING
+#undef HEAD
+#undef TAIL
if(parent2child->fd != -1) {
close(parent2child->fd);