D-Bus connection with pselect()

Thiago Macieira thiago at kde.org
Mon Oct 31 01:21:02 PDT 2011


On Monday, 31 de October de 2011 10:31:03 Michael Pozhidaev wrote:
> Now I want to add D-Bus support to my service and there is one question:
> can I use my already existing pselect() system call to handle D-Bus
> messages when there are present in my D-Bus connection?

Yes, you can. That's how other bindings work too: everything loops around a 
central select / pselect / poll / epoll call.

> I have found
> there is blocking function to wait next D-Bus message and the function
> to check if new message is present but I didn't find anything
> appropriate to use with select() or pselect() messages. I use pselect()
> because there is the requirement to handle signals.

You need to set watch and timeout functions in the connection, as well as the 
thread wakeup one. Then the connection will call your callbacks whenever it 
has to changes to your pselect loop.

Then you tell the connection to handle its timeouts as well as reading and 
writing. After you've given it new data to handle, check the connection's 
dispatcher status and dispatch.

-- 
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: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20111031/ead954c9/attachment.pgp>


More information about the dbus mailing list