windows PID = 0 有效吗?
在Windows中,0是进程的有效PID还是操作系统保留的? 如果您可以提供一个指向文档的链接,说明它是保留的或什么的,那就太好了。 感谢!
In Windows, is 0 valid PID for a process or is it reserved by OS?
It would be nice if you can provide a link to a doc that says it is reserved or what.
Thank!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
打开任务管理器 - 切换到进程选项卡(也许单击“查看”、“显示列”并启用 PID 列)。
PID 0 是系统空闲进程。由于该进程并不是真正的进程并且永远不会退出,因此我怀疑情况总是如此。
我没有可用的文档,但我很确定情况总是如此。
Open task manager - switch to the processes tab (maybe click "View", "Show columns" and enable the PID column).
PID 0 is the System Idle Process. Since that process isn't really a process and never exits, I suspect that it is always the case.
No documentation available to me, but I'm pretty certain this is always going to be the case.
它没有在任何地方说明,但归结为内核句柄表的工作方式。这个相同的对象用于进程句柄和进程/线程 ID。恰好句柄值都从 0x4 开始,而 PsInitialSystemProcess 是第一个创建的进程,因此它的 PID 为 4。空闲进程实际上不是一个进程,您无法打开它。对于大多数意图和目的来说,它可能没有 PID,但大多数工具认为它是 0。
It's not stated anywhere but it comes down to how the kernel handle table works. This same object is used for both process handles and process/thread IDs. It happens that handle values all start at 0x4, and PsInitialSystemProcess is the first process to be created, so it gets a PID of 4. Idle process isn't actually a process and you can't open it. It probably doesn't have a PID for most intents and purposes but most tools consider it to be 0.
PID 0 是为空闲“伪进程”保留的,就像 PID 4 是为系统(Windows 内核)保留的一样。
我找不到任何关于指定位置的文档,但通过任何 API(性能计数器、WMI)查询进程将始终为您提供 PID 0 的空闲进程。
The PID of 0 is reserved for the Idle "psuedo-process", just like PID of 4 is reserved for the System (Windows Kernel).
I can't find any documentation on where that is specified, but querying the processes via any API (Perf Counters, WMI) will always give you the idle process for PID 0.