返回资讯中心
外部精选
软件工程
#社区热议

How long do you need to hold down the power button to turn off a PC?

Raymond Chen published another story from the Windows development trenches, this time about what happens when you hold down the power button.

Hacker NewsArodex2026/10/31 · 2 天前17 分钟阅读

以下正文同步自 Hacker News,版权归原站所有,已转换为易读排版。

Raymond Chen published another story from the Windows development trenches, this time about what happens when you hold down the power button.

If you hold a PC’s power button for 12 seconds, it will turn off at the hardware level without notifying the operating system. This is a safety feature so that you can turn of the computer even if the operating system’s “Shut down” command isn’t working.

After eight seconds of the power button being held down, the Windows kernel realizes that the user is trying to do a force-power-off of the system, and it quickly takes a kernel dump that can be uploaded to the Windows Error Reporting service the next time you turn the system on.

I’m a bit confused by these numbers, because I have never seen a PC take this long to power off when holding down the power button; usually it takes only a few seconds to do so, meaning Windows would never generate said kernel dump. I tried reading through the various ATX specification documents to find more information on this, but then I remembered I’m not an electrical engineer so I have no idea what I’m looking at.

The baseline is that ATX always provides standby power to the motherboard, and pressing the power button shorts the power button pin to ground, telling the PSU to power on fully. Pressing the power button if the computer is running tells the operating system to initiate a shutdown (although you can change this behaviour), but if you hold the button down for a certain number of seconds, it forces a power-off. So far, so good; basic information.

It seems that the length of time you need to hold down the power button to force a power-off is dependent on the motherboard in question, handled by a microcontroller or some other IC. Virtually every source I can find says this timing is set to about 4-5 seconds, which is quite a bit shorter than the number of seconds given by Chen. Perhaps motherboard manufacturers consider the 12 seconds to be too long, and just do their own thing, regardless what the ATX specification suggests?

What further complicates matters is that Chen details how the kernel dumps created after pressing the power button for 8 seconds do, in fact, get sent to Microsoft once the computer turns on again. In fact, he is one of the people who gets to see these dumps and respond to them, so obviously they are indeed rolling in. Does this mean there’s a huge number of computers out there that require you to hold down the power button for 12 seconds to force a shutdown that nobody’s ever seen?

These emergency kernel dumps are internally classified as “long power button hold” (LPBH) failures. One of the pieces of information recorded in these emergency kernel dumps is whether the screen consists entirely of black pixels. Those failures are sub-classified as “black screen LPBH”, and they go to a special virtual team for analysis. (I happen to be a member of this black screen LPBH team.)

What’s going on here? Obviously, I’m not going to doubt Chen, so there must be something here I don’t quite understand or that I’m missing. The ATX specification might suggest 12 seconds, but could Windows perhaps adapt its kernel dump behaviour – dumping much sooner than 8 seconds – based on the motherboard it’s running on, maybe through information provided by the chipset drivers?

I would love it if someone more knowledgeable than me can help us unravel this small mystery.

I’m a bit confused by these numbers, because I have never seen a PC take this long to power off when holding down the power button; usually it takes only a few seconds to do so, meaning Windows would never generate said kernel dump. I tried reading through the various ATX specification documents to find more information on this, but then I remembered I’m not an electrical engineer so I have no idea what I’m looking at.

I am also confused with what Chen’s talking about. Most systems power off after 4 or 5 seconds. If microsoft coded it the way it’s described in the blog, it simply would not work for most computers. A commenter on his website said this too, so maybe Chen will respond with an update.

I don’t believe the ATX specification would have anything to say about this, it’s a function of the motherboard. I searched the manual of 3 different manufactures and they all say the same thing…

Soft-Off by PWR-BTTN

Configures the way to turn off the computer in MS-DOS mode using the power button.

Instant-Off Press the power button and then the system will be turned off instantly. (Default)

Delay 4 Sec. Press and hold the power button for 4 seconds to turn off the system. If the power

button is pressed for less than 4 seconds, the system will enter suspend mode.

Click the Start button, and then click Shut Down.

or

If the computer is not responding, press and hold the power button for approximately 5 seconds

or until the computer turns off.

Note: If you cannot power off the computer normally, press and

hold the power button for more than four seconds to shut down

the computer. If you turn off the computer and want to turn it on

again, wait at least two seconds before powering up.

Furthermore, I am skeptical of windows being able to detect a long press at all. I don’t believe ACPI reports this information. Maybe it could just be a linux limitation. By sheer coincidence a patch was submitted for this very issue a few weeks ago…

https://lkml.iu.edu/2610.1/10586.html

The ACPI button driver only recognizes notify value 0x80 and

always synthesizes a press followed by an immediate release.

This makes it impossible for userspace to determine the actual

duration of a power button press.

However the actual ACPI specs do NOT show a key release for the power button event at all.

https://uefi.org/specs/ACPI/6.6/05_ACPI_Software_Programming_Model.html#control-method-power-button-notification-values

Hex value | Description

0x80 | S0 Power Button Pressed. Used to notify OSPM that the power button has been pressed while the system is in the S0 state. Notice that when the button is pressed while the system is in the S1-S4 state, a Device Wake notification must be issued instead.

0x81-0xBF | Reserved

So I think this puts the veracity of the entire blog post in question. It’s possible Chen is just misremembering how the function works. It could be that there is an 8 second interval to trigger a kernel dump, but rather than a long button press (which would clearly shut down the computer), windows is looking for two button presses in this interval. That seems plausible and sort of aligns with the feature Chen describes.

I won’t test this myself because I don’t really feel like testing hard shutdowns on the only windows computer I have for work. Someone else can test it and report back 🙂 I know that on linux mint, one button press triggers a shutdown dialog with a 30 second countdown and a second button press starts the shutdown right away.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →