arm-0003-Revert-alpm_run_chroot-always-connect-parent2child-p.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From dd8d526a39c86c300f158c581e028365efe60a64 Mon Sep 17 00:00:00 2001
  2. From: Kevin Mihelich <kevin@archlinuxarm.org>
  3. Date: Fri, 11 Mar 2016 20:11:24 -0700
  4. Subject: [PATCH 3/3] Revert "alpm_run_chroot: always connect parent2child
  5. pipe"
  6. This reverts commit 1d6583a58da0904fb7feafd4a666391087955a7b.
  7. ---
  8. lib/libalpm/util.c | 13 +++++++------
  9. 1 file changed, 7 insertions(+), 6 deletions(-)
  10. diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
  11. index c9fdd4af..2d57b256 100644
  12. --- a/lib/libalpm/util.c
  13. +++ b/lib/libalpm/util.c
  14. @@ -592,7 +592,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
  15. goto cleanup;
  16. }
  17. - if(socketpair(AF_UNIX, SOCK_STREAM, 0, parent2child_pipefd) == -1) {
  18. + if(stdin_cb && socketpair(AF_UNIX, SOCK_STREAM, 0, parent2child_pipefd) == -1) {
  19. _alpm_log(handle, ALPM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno));
  20. retval = 1;
  21. goto cleanup;
  22. @@ -612,9 +612,11 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
  23. close(2);
  24. while(dup2(child2parent_pipefd[HEAD], 1) == -1 && errno == EINTR);
  25. while(dup2(child2parent_pipefd[HEAD], 2) == -1 && errno == EINTR);
  26. - while(dup2(parent2child_pipefd[TAIL], 0) == -1 && errno == EINTR);
  27. - close(parent2child_pipefd[TAIL]);
  28. - close(parent2child_pipefd[HEAD]);
  29. + if(stdin_cb) {
  30. + while(dup2(parent2child_pipefd[TAIL], 0) == -1 && errno == EINTR);
  31. + close(parent2child_pipefd[TAIL]);
  32. + close(parent2child_pipefd[HEAD]);
  33. + }
  34. close(child2parent_pipefd[TAIL]);
  35. close(child2parent_pipefd[HEAD]);
  36. if(cwdfd >= 0) {
  37. @@ -649,16 +651,15 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
  38. child2parent->events = POLLIN;
  39. fcntl(child2parent->fd, F_SETFL, O_NONBLOCK);
  40. close(child2parent_pipefd[HEAD]);
  41. - close(parent2child_pipefd[TAIL]);
  42. if(stdin_cb) {
  43. parent2child->fd = parent2child_pipefd[HEAD];
  44. parent2child->events = POLLOUT;
  45. fcntl(parent2child->fd, F_SETFL, O_NONBLOCK);
  46. + close(parent2child_pipefd[TAIL]);
  47. } else {
  48. parent2child->fd = -1;
  49. parent2child->events = 0;
  50. - close(parent2child_pipefd[HEAD]);
  51. }
  52. #define STOP_POLLING(p) do { close(p->fd); p->fd = -1; } while(0)
  53. --
  54. 2.17.0