core: events: correctly handle POLLNVAL in gpiod_line_event_wait()
authorBartosz Golaszewski <bartekgola@gmail.com>
Sat, 14 Apr 2018 20:20:53 +0000 (22:20 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Sun, 15 Apr 2018 17:15:28 +0000 (19:15 +0200)
commitd3ea4f41484693320153bae226c27c507afef00c
tree460d89b3d1e32227e7ff556a45fbe0dc1dc5c980
parenta178da8c95f2fda20278763e9bfea679718eec3e
core: events: correctly handle POLLNVAL in gpiod_line_event_wait()

The only error that can be indicated by ppoll() in the revents field
of struct pollfd when polling a line events file descriptor is
POLLNVAL. It can happen if the user calls close() on said descriptor
after retrieving it with gpiod_line_event_get_fd().

Currently we would act as if there's a line event to read. Make
gpiod_line_event_wait() and its bulk variant return -1 and set errno
to EINVAL in this case.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
src/lib/core.c
tests/tests-event.c