How to detect when a shutdown is completed and it's save to power off?

Started by Chris, February 08, 2015, 05:50:31 PM

Previous topic - Next topic

Chris

As already said in the subject:
How can I detect when a shutdown is completed and it's save to power off? I mean there's no visible information on the board itself, the power led is still on - is there any pin that provides the status "save to power off"?

MBR

I think that the easiest way is to use a LED configured as a heartbeat (see https://www.kernel.org/doc/Documentation/leds/leds-class.txt), so the LED will blink as long as the kernel itself is running. When the blinking stops, you can turn the power off.

Chris

This method seems not to be very save as user processes stop much earlier than the system shutdown is completed.

MBR

The heartbeat (implemented via the LED class) is not a user process, it's a kernel thread, so when you terminate and/or kill all user processes during the shutdown, the heartbeat will be still blinking until the time when the kernel displays "System halted", "Poweroff" or somethink like that.