Colibri iMX6 512 MB IT
Hi everyone,
does anyone know the best, fastest and relatively safe method of shutting down my iMX6?
I know that at the dos prompt, i can type for example:
sudo shutdown now
but there are two problems:
- In my application, there is no screen or terminal to type on. I would like to use a GPIO to run the command from C.
When i try this, I get messages like
sudo: shutdown: command not found
I also tried to use sudo systemctl but I see now that systemd is not installed…
The internet is full of ideas, such as this thread on superuser.:
but I guess what i am after is something that will shut down relatively safely in under 5 seconds, if possible.
the 2nd part of my problem, is that I believe my programs themselves are part of the problem. They do not respons to SIGINT, SIGTERM, SIGKILL etc. i am a bit of a linux N00b, so if anyone has some sample code they would like to share…
I think I want my program to receive the GPIO, give the command to shutdown which will hopefully shut down my other python programs and then close up some files and call exit(0);
// https://linux.die.net/sag/shutdown.html
sprintf(systemCommand, "echo password | sudo shutdown -r now"); // shut down the system
system(systemCommand);
printf("Attempting to shut down...\n");
exit(0);
- How to respond to SIGTERM in python?
PS the reason it needs to be fast, is that if power is lost to our system I have proposed that we read a digital input of the supply voltage (at an earlier stage) and then some sort of supercapacitor near the Colibri to allow the system to shut down “as gracefully as possible”. I may need about a 2F capacitor for this. Is there anyone else who has this issue?
Seems to take about 10 seconds with nothing running on it at the moment.
Anything is helpful, thanks!