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

Thiago Macieira thiago at kde.org
Fri Dec 13 08:51:54 PST 2013


On sexta-feira, 13 de dezembro de 2013 16:18:36, Andrew Cann wrote:
> 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?

Just ignore them. If you pass just read and write activity to the reference 
library, it will be enough. Hangups will be detected by a read activity 
notification followed by a read() call returning 0.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20131213/d5fb7c3e/attachment.pgp>


More information about the dbus mailing list