0

The g_poll() function returns -1 "on error or if the call was interrupted". (See: https://developer.gnome.org/glib/2.28/glib-The-Main-Event-Loop.html#g-poll).

If g_poll returns -1 how do I determine if this was because the call was interrupted vs. if there was an error?

If it was an error, how do I determine the cause of the error? Is it sufficient to look at errno?

benno
  • 2,077
  • 1
  • 19
  • 23

1 Answers1

4

Yes. Check errno if g_poll() returns -1. The documentation also says

gpoll() polls fds, as with the poll() system call, but portably.
On systems that don't have poll(), it is emulated using select().

i.e. g_poll() uses poll() and select() internally.
Hence, check the various scenarios that errno is set to various values by poll() and select()

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130