Safe Shutdown by power-on button - BeagleBoard-X15

Hello,

we are trying to implement a controlled shutdown in BBX15 by pressing the power-on button: as default, if you press and hold the power-on
button for about 12seconds the power-off is forced and you risk to corrupt the filesystem…

Does anyone know if there is a way to detect the interrupt generated by the power-on button, and combine it to a safe shutdown procedure ?

Thanks,
Regards.

Mario