How to deny shutdown when pressing the power button for a while?

I would hope that you can't do this. I've run into situations a number of times where I couldn't reboot the computer in any other way. In such cases, do you really want to force a laptop user to unplug the power supply and remove the battery while running?

Having given that warning, you may be writing software for rather different situations where it makes more sense. Could you give more details about the motivation for this?

If a user is able to hold the power button down (indicating that they really, really want to shut the machine down) are they unable to physically remove power?

EDIT: Responding to the comment from magsto:

If everyone involved really, really wants this - having explained to them that if things go wrong and they need to hard-reset the computer, they'll have to go to an even more direct way of powering down, which I suspect is more likely to damage hardware than the "hold down power" method... talk to the device manufacturer. It sounds like you're probably working with a specific device, so they may be able to tweak something in the BIOS for you, even if it's not a publicly available option.

Given that this is almost always a really bad idea, I'm not surprised there isn't simple support for it, but if you ask the manufacturer there may be some hidden way of doing what you want. I'd still encourage you to get everyone involved to think about all the potential consequences though.


See page 62 of the ACPI spec in relation to the 4-second rule (http://www.acpi.info/DOWNLOADS/ACPIspec30b.pdf)

Long and the short of it is that the logic is in hardware.


It is indeed a mechanical power off, so it will be kind of difficult to circumvent.

If it's really important, you could disconnect the power button and turn the computer on/off with wake-on-lan resp. remote shutdown.