libchromeos: Watch file descriptors on error conditions.

When watching for a file descriptor, guaranties are that the callback
will be called if a call to read() or write() (depending on what are
you watching for) will not block even if the file descriptor doesn't
have the O_NOBLOCK flag set. This is normally because there is data to
read or it is possible to write data, but can also be because the
file descriptor is closed (invalid) or the end of file or device is
reached. In the last two cases, a read() or write() will return
immediately with an error or a value of 0, but won't block.

This patch makes GlibMessageLoop implementation watch for those cases
as well.

BUG=None
TEST=Added unittests.

Change-Id: I7d9d7671165ebf08b459cfff5d52bd09e6daabc1
Reviewed-on: https://chromium-review.googlesource.com/284711
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
2 files changed