]> git.ipfire.org Git - thirdparty/libvirt.git/commit
commandtest: Comply with FreeBSD poll()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Dec 2022 15:23:55 +0000 (16:23 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Dec 2022 16:24:31 +0000 (17:24 +0100)
commit2ae1f19d4385cf5d4b864c52d37e145cfc607cb8
treefa57f72512da507dd84a92dabc98b731fe30bd95
parenta156b69c3578e20c5ebbd84c2f7ffbda4f243a1f
commandtest: Comply with FreeBSD poll()

In one of recent commits I've introduced a new test case to
commandtest. In the test case I'm using poll() to wait for data
on a pipe (the write end is passed to commandhelper). However, on
FreeBSD the POLLIN semantic is a bit different:

  POLLIN        Data other than high priority data may be read
                without blocking.

Well, the pipe is non-blocking, so even if there's no data to be
read the flag is set (and subsequent read() returns 0). On the
other hand, POLLHUP is set too, BUT, if the commandhelper manages
to write everything into the pipe and die right after we'd get
both POLLIN and POLLHUP after the very first time poll() returns.
That's very unfortunate, but okay - we can just check whether
read() returned zero and break from the reading loop.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
tests/commandtest.c