From: Roman Bogorodskiy Date: Tue, 21 Apr 2015 17:11:32 +0000 (+0300) Subject: vircommand: fix polling in virCommandProcessIO X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e34cccf783983e1b19f139bde873e950424a8778;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git vircommand: fix polling in virCommandProcessIO When running on FreeBSD, there's a bug in virCommandProcessIO polling that is triggered by the commandtest. A test that triggers EPIPE in commandtest (named "test20") hungs forever on FreeBSD. Apparently, this happens because FreeBSD sets POLLHUP flag on revents when stdin in closed. And as the current implementation only checks for POLLOUT and POLLERR, it ends up looping forever inside virCommandProcessIO and not trying to do one more write() that would trigger EPIPE. To fix that check for the POLLHUP flag along with POLLOUT and POLLERR. --- diff --git a/src/util/vircommand.c b/src/util/vircommand.c index c41bd7f69..c7f153860 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2093,7 +2093,7 @@ virCommandProcessIO(virCommandPtr cmd) } } - if (fds[i].revents & (POLLOUT | POLLERR) && + if (fds[i].revents & (POLLOUT | POLLHUP | POLLERR) && fds[i].fd == cmd->inpipe) { int done;