summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2018-10-13 04:16:53 +0200
committerAndrew Gregory <andrew@archlinux.org>2018-11-19 02:25:18 +0100
commit3a88fcb19199c5b5fa18162f5f9dc8990311dbd2 (patch)
treecf3fa3f9ec6039ae97a651576db900fd7e5d0000 /lib/libalpm
parent2a7bdd3e3aabbf9fa3cc31379cadad909e6c1da3 (diff)
downloadpacman-3a88fcb19199c5b5fa18162f5f9dc8990311dbd2.tar.gz
pacman-3a88fcb19199c5b5fa18162f5f9dc8990311dbd2.tar.xz
handle EINTR while polling scripts/hooks
If poll() is interrupted by a signal, alpm was closing the socket it uses for listening to script/hook output. This would drop script output at the least and kill the script at the worst. Fixes FS#60396 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org> (cherry picked from commit ac959bb9c6ce549047a954109ae825158855e386)
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/util.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index eaf85e93..d33eef2a 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -665,6 +665,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
ssize_t olen = 0, ilen = 0;
nfds_t nfds = 2;
struct pollfd fds[2], *child2parent = &(fds[0]), *parent2child = &(fds[1]);
+ int poll_ret;
child2parent->fd = child2parent_pipefd[TAIL];
child2parent->events = POLLIN;
@@ -685,7 +686,14 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
#define STOP_POLLING(p) do { close(p->fd); p->fd = -1; } while(0)
while((child2parent->fd != -1 || parent2child->fd != -1)
- && poll(fds, nfds, -1) > 0) {
+ && (poll_ret = poll(fds, nfds, -1)) != 0) {
+ if(poll_ret == -1) {
+ if(errno == EINTR) {
+ continue;
+ } else {
+ break;
+ }
+ }
if(child2parent->revents & POLLIN) {
if(_alpm_chroot_read_from_child(handle, child2parent->fd,
ibuf, &ilen, sizeof(ibuf)) != 0) {