Best way to shut down programmatically - poweroff?


#1

Using the cli, # poweroff does exactly what I want: a total power-down.
I have seen other posts that describe using system(“poweroff”) in app-code.
But my Wp7601 with Legato 18.08 doesn’t seem to include it.

I entered these lines into my app:
system(“pwd”);
system(“ls”);
system(“poweroff”);
The first two linux system calls result in a reasonable output as shown below, but the “poweroff” call is not found.

Has it been replaced?

Feb 27 05:54:49 swi-mdm9x28 user.info Legato: INFO | maxTrack[1485] | /legato/systems/current/appsWriteable/maxTracker
Feb 27 05:54:49 swi-mdm9x28 user.info Legato: INFO | maxTrack[1485] | bin dev etc lib sys usr

Feb 27 05:54:49 swi-mdm9x28 user.err Legato: =ERR= | maxTrack[1485] | sh:
Feb 27 05:54:49 swi-mdm9x28 user.err Legato: =ERR= | maxTrack[1485] | poweroff: not found
Feb 27 05:54:49 swi-mdm9x28 user.err Legato: =ERR= | maxTrack[1485] |


#2

Ok, that was an easy one.
system("/sbin/poweroff -f");
is a line that works for me.


#3

Can I ask why you’re trying to programmatically power off? There won’t be any way to power back on again without physically interacting with the unit right? Is that ok?