Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

windows PID = 0 valid?

Tags:

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!

like image 995
user156144 Avatar asked Jul 12 '10 21:07

user156144


People also ask

How do I show PID in Windows?

How to get PID using Task Manager. Press Ctrl+Shift+Esc on the keyboard. Go to the Processes tab. Right-click the header of the table and select PID in the context menu.

What does it mean if PID is 0?

The if (PID == 0) evaluates the return value. If PID is equal to zero then printf() is executed in the child process, but not in the parent process. The else part of the condition is executed in the parent process and the child process but only the parent process will execute the else part of the condition.

What does PID mean Windows?

Each process running in Windows is assigned a unique decimal number called the process ID (PID). This number is used in a number of ways, for example to specify the process when attaching a debugger to it.

Is 0 a valid PID?

No error signal would cause any correction. However, zero is not very useful as a PID in a controller, but technically, it's valid. Hence, the PID 0 is often referred to as an idle process.


2 Answers

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.

like image 149
developmentalinsanity Avatar answered Sep 19 '22 16:09

developmentalinsanity


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.

like image 27
wj32 Avatar answered Sep 19 '22 16:09

wj32