با توجه به جواب های شما شد این ، لطفاً بگید تحلیل من کجاش اشتباست.
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
int main()
{
pid_t pid_1;
pid_t pid_2;
pid_t pid_3;
pid_t pid_4;
pid_1=fork();
pid_2=fork();
pid_3=fork();
pid_4=fork();
if(pid_1==0)
{
printf("The proccess is child and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
else
{
printf("The proccess is parent and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
if(pid_2==0)
{
printf("The proccess is child and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
else
{
printf("The proccess is parent and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
if(pid_3==0)
{
printf("The proccess is child and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
else
{
printf("The proccess is parent and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
if(pid_4==0)
{
printf("The proccess is child and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
else
{
printf("The proccess is parent and id is %d",getpid());
printf("The proccess is parent and id is %d",getppid());
}
}