I have an embedded Linux system (currently running Angstrom) with supercapacitor hardware to provide time for writes to complete and avoid corrupted filesystems when external power is removed.  Architecture is ARM, SOC is Freescale iMX6QThere's a GPIO input that monitors the presence of external power.What's the best way to hook this input to the existing logic for powerfail handling?  Should I broadcast SIGPWR to all running processes myself?  Raise it only to systemd?  Write something to /dev/initctl?  Do something else so that the kernel itself sends out SIGPWR?Is there an existing mechanism for hardware powerfail inputs that I can configure in devicetree?  Or is a user-mode daemon (with high priority) polling a sysfs gpio file the best approach?This earlier question pointed out the advantages of battery backup, but stopped with keep power on long enough without getting into any details of how to trigger the powerfail path in write flushing code.  (Since loss of power is imminent, the system should not waste any time in normal process shutdown, only perform operations that protect data integrity.  Especially operations that log shutdown should be avoided, because they increase the chance of corruption by performing writes, including updates to wear-leveling data, at the worst possible time.  Discussion.)
Triggering Linux shutdown on power failure
linux;systemd;power management;gpio