dimanche 28 août 2016

How to create chain of processes in C?

I need to create 5 processes one being father of the second, grandpa of the third etc. All of them have to wait for each other to finish. I tried the approach with:

switch (pid = fork()) {
  case 0: 
    printf("Child PID = %dn", getpid());
    printf("parent: =%dn", getppid());
    return 0;

default:
  break;

But I always get the same parent.

Aucun commentaire:

Enregistrer un commentaire