Correct way to shutdown or reboot system from a snap?


#1

I am trying to shutdown/reboot the system from inside a snap

(snap 2.42 / Ubuntu 16.04LTS)

I have connected the interface and “snap connections mysnap” shows :

shutdown mysnapp:shutdown :shutdown manual

So I guess the interface is connected.

When my cpp code trigger a sysexec of “shutdown -h now” or “shutdown -r now” I don’t get anything (and I also don’t know much how to debug this problem further).

Any hint ?


#2

I don’t remember how to do this, but I remember there’s some weirdness around restarting/shutting down on UC. @ogra do you know how to do this?


#3

the interface doesnt allow ditect access to the shutdown binary but opens access to logind via dbus … so you need to send a command to logind like:


#4

@ogra thank you ! I will explore that !