Re: [systemd-devel] Reading an "ao" signature message with the sdbus c library?

2017-08-17 Thread James Johnson
Hello,


It looks like I figured out my problem, I have to use:

result = sd_bus_message_enter_container(msgCall, 'a', "o");

before I try reading the array with :

result = sd_bus_message_read(msgCall, "o", );

Thanks,
Jimmy

On Thu, Aug 17, 2017 at 1:43 PM, James Johnson 
wrote:

> Hello,
>
> Can someone please point me to the correct method for reading an "ao"
> signature dbus message using the sd_bus C api?
>
> I am trying to read all the network devices with the following call:
>
>   result = sd_bus_get_property(m_bus, "org.freedesktop.NetworkManager",
>  "/org/freedesktop/NetworkManager",
>  "org.freedesktop.NetworkManager",
>  "AllDevices", ,
>  , "ao");
> I have tried:
>
> char * ptr;
> size_t size;
>
> result = sd_bus_message_read_array(msgCall, 'o', , );
>
> as well as:
>
> result = sd_bus_message_read(msgCall, "ao", ptr);
>
> but these both return an error. I am not sure what method to use to parse
> the returned message when it is an array of path objects.
>
> Please note this interface gives me the following when executed via the
> busctl command:
>
> [jjohnson@macbookpro]$ busctl --verbose get-property
> org.freedesktop.NetworkManager /org/freedesktop/NetworkManager
> org.freedesktop.NetworkManager AllDevices
> ARRAY "o" {
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/1";
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/3";
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/11";
> OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/12";
> };
>
>
> Thanks!
> Jimmy
>
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Reading an "ao" signature message with the sdbus c library?

2017-08-17 Thread James Johnson
Hello,

Can someone please point me to the correct method for reading an "ao"
signature dbus message using the sd_bus C api?

I am trying to read all the network devices with the following call:

  result = sd_bus_get_property(m_bus, "org.freedesktop.NetworkManager",
 "/org/freedesktop/NetworkManager",
 "org.freedesktop.NetworkManager",
 "AllDevices", ,
 , "ao");
I have tried:

char * ptr;
size_t size;

result = sd_bus_message_read_array(msgCall, 'o', , );

as well as:

result = sd_bus_message_read(msgCall, "ao", ptr);

but these both return an error. I am not sure what method to use to parse
the returned message when it is an array of path objects.

Please note this interface gives me the following when executed via the
busctl command:

[jjohnson@macbookpro]$ busctl --verbose get-property
org.freedesktop.NetworkManager /org/freedesktop/NetworkManager
org.freedesktop.NetworkManager AllDevices
ARRAY "o" {
OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/1";
OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/3";
OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/11";
OBJECT_PATH "/org/freedesktop/NetworkManager/Devices/12";
};


Thanks!
Jimmy
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] type=notify not working as intended

2017-08-17 Thread Jouke Witteveen
On Tue, Aug 15, 2017 at 5:59 AM, Kalpa Gunarathna  wrote:
> Hello all,
>
> I have scripted a service unit as follow.
>
> [Unit]
> Description="A test service"
> After=epmd.service epmd.socket
>
> [Service]
> ExecStart=/home/otpuser/bin/start
> Type=notify
> NotifyAccess=all
> WorkingDirectory=~
> User=otpuser
> Group=otp
> Restart=always
> RestartSec=3
>
> [Install]
> WantedBy=multi-user.target
>
>
> ExecStart directs to a shell script which starts a Erlang run_erl daemon.
> This daemon is forking a process which is the BEAM virtual machine. In the
> forked process Im sending "READY=1\nSTATUS=Initialized\nMAINPID="
> <> "\n to systemd via sd_notify. The problem is service
> is getting restarted constantly.
>
> journalctl give this
>
> abc.service: Service hold-off time over, scheduling restart.
> Stopped "A test service.".
>
>
> Is it required to send READY=1 from the daemon it self ? or can systemd
> allow forked process of the daemon to send REDAY=1 notification?
>
> It works when Type=forking and PIDFile is specified, but can we have
> Type=forking and without PIDFIle, notify READY=1 via forked process ?
>
> My systemd version
>
> $ systemd --version
> systemd 229
>

The service fails when the main process terminates before a READY=1
notification is received. Contrary to Reindl Haralds claim, this
notification is allowed to come from whatever process that is allowed
to send notifications, as controlled by NotifyAccess=. In order to not
give up on the service when the main process terminates, but wait for
the remaining processes in the cgroup, you should add
RemainAfterExit=yes to your unit.

Regards,
- Jouke
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel