Is it possible to detect loss of power on a laptop/desktop without an UPS? Obviously a computer without an UPS will shutdown at least almost immediately after being unplugged/having its battery pulled. However, I thought maybe that the kernel could notice the loss of power before the capacitors/inductors drained completely and have a very short chance to do something.
I know if I have a properly configured UPS,
powerd will send
init so an organized shutdown can happen. I'm interested in the case where I don't have an UPS attached, so obviously there would be at best a very short window in which to shutdown. All I'd really want is to write a single timestamp (or failing that, any string) to a logfile so I could know about the power failure.
I somehow doubt that
SIGPWR will actually be helpful in this case, since I doubt the kernel is going to send it to every single process, it was just the first thing that came to mind. Perhaps there would be some control line or file I could poll on that the kernel would update? Or perhaps I'm just screwed, which to be honest is kind of what I expect.