mardi 11 août 2020

Example fork() process with if else

void main{}
{
pid_t pid;
pid = fork();  // parent and child
pid = fork();  // -> is this now child and child or parent and child?
printf{"hello};
pid = fork();  // same question, but this should be like 2^3 processes? so 8 Process right?
if (pid>0);    // here im checking only the parent(=1)? 
{
pid=fork();    // is it right that now i only fork the parents? my thougt now is 8 process, and from those 8 are 4 Parents? means 8 new processes? i hope im still right
{ 
else pid=fork  // this would only occure if pid==0? 
}

Hopefully you guys could understand my intention and someone can help me if my thougts are the right ones? The question is how many processes to i create ? Thanks

Aucun commentaire:

Enregistrer un commentaire