Windows child parent relationship
<!DOCTYPE html>
Understanding Parent and Child Processes in Windows
Each process in the Windows operating system points to its parent process, which is basically the creator process. However, if the creator process, or what is called the parent process, is terminated, the information related to that process won't be updated. Therefore, the child process might refer to a non-existent process.
Demonstrating the Parent-Child Process Relationship
We will be conducting an experiment to show the child/parent process relationship in Windows. Let's prove that Windows doesn't keep track of more than one parent process ID.
First, let's demonstrate a simple process list before we dive into the example:
- Press "WIN + R".
- Type "cmd".
- Press "Enter".
- Type
tasklist /svc
.
You should get a long list of running processes, as shown in the following image:
As you can see, the list above shows the processes running on your system. Windows maintains processes by assigning Process IDs (PIDs). We have multiple running processes, but Windows won't be able to identify the process of the process creator beyond the immediate parent because it only maintains and identifies the creator process ID. To prove that Windows doesn't keep track of more than just the parent process ID, I will show you an example.
The Experiment
- Press "WIN + R".
- Type
cmd
. - Press "Enter".
- Type
title parent
and press "Enter". - Type
start cmd
and press "Enter". - In the new command prompt window, type
title child
and press "Enter". - Type
mspaint
to launch Microsoft Paint and press "Enter". - Close the child command prompt by typing
exit
and pressing "Enter".
As you can see, we spawned another command prompt from the first one we launched, which we named "parent".
The new command prompt window titled "child" appears:
We set the title of this command prompt to "child":
Then, we launched Microsoft Paint by typing mspaint
in the child command prompt:
Now, close the child command prompt by typing exit
. After you do that, you will notice that Microsoft Paint remains open even though we have closed the terminal we spawned it from.
Next, launch your Task Manager by pressing "CTRL + Shift + Esc".
Locate the cmd
process we have running, which is titled "parent":
As you can see, the parent process is displayed.
Right-click the Windows Command Processor, then click on "Go to Details".
Right-click the cmd.exe
process and select "End process tree". This will terminate all processes in the tree.
As you can see, the "parent" command prompt will disappear, but Microsoft Paint will still be running because it was the grandchild of the process we terminated. Since the intermediate process was killed, there was no link between the parent and the grandchild.
I really hope you enjoyed this basic little article I wrote. This might come in handy for some people out there. I just wanted to share this information about Windows. :)
Hussein A. Muhaisen