How to use watches with the DBus C API and select()

Andrew Cann shum at
Fri Dec 13 00:18:36 PST 2013

Hello all. I'm building a small DBus library and I'm wondering if it's
possible to use watches with a select() based main loop. The problem with
select is I can only detect whether a socket is readable/writable, I don't
have any method (that I know of) to correctly set DBUS_WATCH_ERROR and
DBUS_WATCH_HANGUP when calling dbus_watch_handle. Is it sufficient to check for
errors and hangups through select's read and write sets and trust libdbus to
handle the situation correctly when it fails to read from or write to the file
descriptor? Or do I really have to use poll() for something like this?

Excuse my ignorance, any help is appreciated.
 - Andrew

More information about the dbus mailing list