πProcess ID
In this section we shall see what is a PID (process id) and how we can retrieve the PID of a process as well as its parent process
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[]){
fork();
printf("Current ID: %d Parent ID: %d\n",getpid(), getppid());
return 0;
}Outputs
Current ID: 8771 Parent ID: 2353
Current ID: 8772 Parent ID: 8771Current ID: 8388 Parent ID: 2353
Current ID: 8389 Parent ID: 8388Current ID: 8800 Parent ID: 2353
Current ID: 8801 Parent ID: 8800Output
Output
Explanation
Last updated