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.

(cherry picked from commit e34cccf783)
This commit is contained in:
Roman Bogorodskiy 2015-04-21 20:11:32 +03:00 committed by Cole Robinson
parent e84e5aa3df
commit b5a210dce7

View File

@ -2073,7 +2073,7 @@ virCommandProcessIO(virCommandPtr cmd)
}
}
if (fds[i].revents & (POLLOUT | POLLERR) &&
if (fds[i].revents & (POLLOUT | POLLHUP | POLLERR) &&
fds[i].fd == cmd->inpipe) {
int done;