[systemd-devel] How to get argument list for methods

Chris Kottaridis chris at quietwind.net
Tue Jun 17 03:26:03 UTC 2025


I am beginning to use the sd-bus library. I have been able to get a couple of properties, MainPID and SubState.

I would like to use the Stop method. I am using cups as an example. This commands shows that in thee Unit interface there is a Start and Stop method:

$ busctl introspect org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/cups_2eservice

NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS

org.freedesktop.systemd1.Unit       interface -               -                                        -

.Start                              method    s               o                                        -
.Stop                               method    s               o                                        -

Each has a signature of "s" I assume it takes one parameter of type string.

I have tried the sample on this page. Pasting it into a file and compiling and running it works
great.

https://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html

This sample starts the cups service by acccessing the systemd Manager and calling StartUnit.

|/* Issue the method call and store the respons message in m */ 
r=sd_bus_call_method(bus, "org.freedesktop.systemd1",/* service to 
contact */ "/org/freedesktop/systemd1",/* object path */ 
"org.freedesktop.systemd1.Manager",/* interface name */ "StartUnit",/* 
method name */ &error,/* object to return error in */ &m,/* return 
message on success */ "ss",/* input signature */ "cups.service",/* first 
argument */ "replace");/* second argument */ It has a signature of "ss" 
which I assume means the method takes 2 arguments each of a type string. 
My question is for any given method how do I get what the arguments for 
it are ? Like if I use Start what are valid values to pass for the one 
argument? In StartUnit the first argument seems obvious with an example 
to be the unit you want to start. I am not sure what the "replace" means 
or what other strings would be valid. Again I am interested in the Stop 
method specifically, but in general would like to know where I can get a 
list of the arguments and possible values for any method. Thanks Chris |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20250616/ea575a1e/attachment.htm>


More information about the systemd-devel mailing list