[systemd-devel] Monitoring services start event from kdbus with sd-bus API

Thomas Schmidt t.schmidt at md-network.de
Tue Jun 30 02:15:06 PDT 2015

for an embedded project I’m implementing a bootsplash application which should as well display service names are starting.
This is based on kdbus and uses the sd-bus API to communicate with systemd (for example boot process percentage property is polled). 
Now I try to monitor the kdbus (system bus) to capture the events which indicate that a service was started. (works very well for testing with "busctl monitor“ tool).
I assumed that the method_call „StartUnit“ would be a good indicator, so I tried to monitor for those messages by using following code (shortened and only significant parts copied here):

-.-.-.-.-.-.-.-.-.-.-. schnipp -.-.-.-.-.-.-.-.-.-.-

r = sd_bus_open_system(&bus);
r = sd_bus_add_match(bus, NULL, "", do_something_callback,  NULL); /* should not filter anything, I expect it triggers on any message */ 

for (;;) {
	sd_bus_message *m = NULL;

                r = sd_bus_process(bus, &m);
                if (r < 0) {
                        fprintf(stderr, "Failed to process bus: %s\n", strerror(-r));
                        goto finish;

                if (r > 0) /* we processed a request, try to process another one, right-away */

                /* Wait for the next request to process */
                r = sd_bus_wait(bus, (uint64_t) -1);
                if (r < 0) {
                        fprintf(stderr, "Failed to wait on bus: %s\n", strerror(-r));
                        goto finish;


-.-.-.-.-.-.-.-.-.-.-. schnapp -.-.-.-.-.-.-.-.-.-.-

The interesting thing is that this code only sees „signal“ type  messages - but not any other like „method_call“.

I did extensive testing, tried different code variants, for example by processing "sd_bus_message *m“ directly in the for loop with „sd_bus_message_is_method_call“ - but the effect is the same I don’t get „method_call“ as an event.

Is there any suggestion what could be the reason ? (is that generally the right way what I try here to do ?)
Many thanks for any feedback which points me to the right direction
Kind Regards
Thomas Schmidt

More information about the systemd-devel mailing list